-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokemon.java
More file actions
65 lines (53 loc) · 1.19 KB
/
Pokemon.java
File metadata and controls
65 lines (53 loc) · 1.19 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
public class Pokemon {
// Variables de la clase
private String nombre;
private double fuerza;
// Constructor
public Pokemon(int huevo) {
if (huevo == 0) {
nombre = "Pikachu";
fuerza = Math.random() * (60 - 30) + 30;
} else if (huevo == 1) {
nombre = "Squirtle";
fuerza = Math.random() * (50 - 40) + 40;
} else if (huevo == 2) {
nombre = "Charmander";
fuerza = Math.random() * (55 - 45) + 45;
}
}
// Metodos get
public String getNombre() {
return nombre;
}
public double getFuerza() {
return fuerza;
}
// Metodo combatir
public double combatir() {
return fuerza;
}
// Metodo entrenar
public double entrenar() {
return (fuerza += Math.random() * 5);
}
// Metodo nivel
public int nivel() {
int nivel;
if (fuerza >= 0 && fuerza <= 20) {
nivel = 1;
} else if (fuerza > 20 && fuerza <= 40) {
nivel = 2;
} else if (fuerza > 40 && fuerza <= 50) {
nivel = 3;
} else if (fuerza > 50 && fuerza <= 60) {
nivel = 4;
} else {
nivel = 5;
}
return nivel;
}
// Metodo extra (solo para evolucionar)
public void evolucion(String nombre) {
this.nombre = nombre;
}
}