-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokemon.java
More file actions
123 lines (90 loc) · 2.32 KB
/
Pokemon.java
File metadata and controls
123 lines (90 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
public abstract class Pokemon {
protected String name;
protected int HP;
private int maxHP;
private String myName;
private String level ;
private int PP;
private String gender;
public Pokemon(String name)
{
this.name = name;
this.HP = 0;
this.level = "level 1";
this.PP = 0;
}
public Pokemon(String name,int maxHP){
this.name = name;
this.HP = (int)(Math.random() * maxHP)+1;
this.maxHP = maxHP;
this.level = "level " + (int)(Math.random() * 15 )+1;;
this.PP = (int)(Math.random() * 5)+1;;
this.gender = getGender();
}
public void setMyName(String myName){
this.myName = myName;
}
public String getMyName() {
return myName;
}
public String getName() {
return name;
}
public void setName(String name){
this.name = name;
}
public int getHP(){
return HP;
}
public void setHp(int HP){
this.HP = HP;
}
public int getMaxHP(){
return maxHP;
}
public String getLevel(){
return level;
}
public void setLevel(String level){
this.level = level;
}
public int getPP(){
return PP;
}
public void setPP(int PP){
this.PP = PP;
}
public String getGen(){
return gender;
}
public String getGender(){
for(int i = 0 ; i < 1 ; i++) {
int type = (int)(Math.random()*2);
if (type == 0){
gender = "Male";
}
else if(type == 1){
gender = "Female";
}
}
return gender;
}
public boolean damage(int value){
if(PP == 0){
return false;
}
int currentHP = HP - value;
if(currentHP >= 0){
this.HP = currentHP;
}
else {
this.HP = 0;
}
//can setHP
return true;
}
public abstract void attack(Pokemon enemy);
public String toString(){
return "Pokemon : " + name + " HP : " + HP + " " + gender;
}
}