-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokemon.java
More file actions
59 lines (48 loc) · 1.16 KB
/
Pokemon.java
File metadata and controls
59 lines (48 loc) · 1.16 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
import java.util.*;
class Pokemon{
private String name;
private float weight;
private float stepLength;
private int step;
private float gainingWeightStep;
private String[] types;
Random rnd = new Random();
public Pokemon(String name,
float gainingWeightStep,
String[] types){
this.name = name;
this.weight = rnd.nextInt(100)+1;
this.stepLength = (float)(rnd.nextInt(1)+0.1);
this.gainingWeightStep = gainingWeightStep;
step = 0;
if(types == null)
this.types = new String[] {"normal"};
else
this.types = types;
}
public void walk(){
step += 1;
weight -= .5f;
}
public void eat(){
weight += gainingWeightStep;
}
public void print(){
System.out.println("Pokemon name: " + name);
System.out.print("Type: ");
for(String type: types){
System.out.print(type+",");
}
System.out.println();
System.out.println("Weight: " + weight);
System.out.println("Step Length: " + stepLength);
System.out.println("Today Step: " + step);
System.out.println("---------------------------------------------------------");
}
public String getName(){
return name;
}
public void setName(String newName){
this.name = newName;
}
}