-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPet.java
63 lines (53 loc) · 1.59 KB
/
Pet.java
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
import javax.swing.JOptionPane;
public class Pet {
private String nome;
private int fome = 50;
private int felicidade = 50;
private int cansaco = 0;
public Pet(String name) {
this.nome = name;
}
/**
* getters
* */
public void mostrarStatus(){
String message = "Status atual de " + nome + " ;\n" + "Nível de fome: " + fome + "\n Nível de felicidade: " + felicidade + "\n Nível de cansaço: " + cansaco;
JOptionPane.showMessageDialog(null, message);
}
public int mostrarNivelDeFome(){
return this.fome;
}
public int mostrarNivelDeFelicidade(){
return this.felicidade;
}
public String mostrarNome(){
return this.nome;
}
/**
* setters
* */
public void alimentar(){
fome -= 10;
JOptionPane.showMessageDialog(null, nome + " foi alimentado. O nível de fome diminuiu");
}
public void brincar(){
if(cansaco >= 100){
JOptionPane.showMessageDialog(null, "Seu bixinho está muito cansado para brincar!");
}
else{
felicidade += 10;
cansaco += 10;
JOptionPane.showMessageDialog(null, nome + " está brincando e se sentindo mais feliz");
}
}
public void descansar(){
this.cansaco = 0;
JOptionPane.showMessageDialog(null, nome + " está descansado!");
}
public void passarTempo() {
fome += 5;
felicidade -= 5;
cansaco += 10;
JOptionPane.showMessageDialog(null, nome + " está ficando mais faminto com o passar do tempo.");
}
}