-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacter.java
More file actions
84 lines (68 loc) · 1.66 KB
/
Copy pathCharacter.java
File metadata and controls
84 lines (68 loc) · 1.66 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
public class Character {
protected String nome;
protected int vida;
protected int ataque;
protected int defesa;
protected int defesaAtual;
public Character(String nome, int vida, int ataque, int defesa)
{
this.nome = nome;
this.vida = vida;
this.ataque = ataque;
this.defesa = defesa;
this.defesaAtual = this.defesa;
}
public void Atacar(Character adversario){
int vidaRetirada = this.ataque - adversario.defesa;
if (vidaRetirada > 0)
{
adversario.setVida(adversario.vida - vidaRetirada);
System.out.println(nome + " ataca " + adversario.nome + ", que fica com " + adversario.vida + " pontos de vida.");
}
}
public void Defender(){
this.defesaAtual += 5;
}
public int getAtaque(){
return this.ataque;
}
public String getNome(){
return this.nome;
}
public void setAtaque(String nome){
this.nome = nome;
}
public void setAtaque(int novoAtaque){
if (novoAtaque < 0)
{
this.ataque = 0;
}
else {
this.ataque = novoAtaque;
}
}
public int getVida(){
return this.vida;
}
public void setVida(int novaVida){
if (novaVida < 0)
{
this.vida = 0;
}
else {
this.vida = novaVida;
}
}
public int getDefesa(){
return this.defesa;
}
public void setDefesa(int novaDefesa){
if (novaDefesa < 0)
{
this.defesa = 0;
}
else {
this.defesa = novaDefesa;
}
}
}