- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonster.java
More file actions
Latest commit
51 lines (42 loc) · 1.13 KB
/
Copy pathMonster.java
File metadata and controls
51 lines (42 loc) · 1.13 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
packageClassAndObjects;
classMonsterWorks {
publicfinalStringTOMBSTONE = "Here Lies a Dead monster";
privateinthealth = 500;
privateintattack = 20;
privateintmovement = 2;
privatebooleanalive = true;
publicStringname = "Big Monster";
publicintgetAttack() {
returnattack;
}
publicintgetMovement() {
returnmovement;
}
publicintgetHealth() {
returnhealth;
}
publicvoidsetHealth(intdecreaseHealth) {
health = health - decreaseHealth;
if (health < 0 && alive == true) {
alive = false;
}
}
publicvoidsetHealth(doubledecreaseHealth) {
intintDecreaseHealth = (int) decreaseHealth;
health = health - intDecreaseHealth;
if (health < 0) {
alive = false;
}
}
}
//Moster Class
publicclassMonster{
publicstaticvoidmain(String[] args){
MonsterWorksgorilla = newMonsterWorks();
gorilla.name = "Jumbo";
System.out.println(gorilla.name+" got health power: "+gorilla.getHealth());
System.out.println(gorilla.name + " has an attack value of " + gorilla.getAttack());
gorilla.setHealth(30);
System.out.println(gorilla.name+" got attacked, Now Health "+gorilla.getHealth());
}
}