-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMinion.java
90 lines (72 loc) · 1.67 KB
/
Minion.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
public class Minion {
// Instance variables
private int att;
private int hp;
private String entranceQuote;
private String attackQuote;
private String deathQuote;
// Constructor
public Minion(int a, int h, String entQ, String attQ, String dQ) {
att = a;
hp = h;
entranceQuote = entQ;
attackQuote = attQ;
deathQuote = dQ;
}
// Getter method for att
public int getAtt() {
return att;
}
// Getter method for hp
public int getHP() {
return hp;
}
// Getter method for entranceQuote
public String getEntranceQuote() {
return entranceQuote;
}
// Getter method for attackQuote
public String getAttackQuote() {
return attackQuote;
}
// Getter method for deathQuote
public String getDeathQuote() {
return deathQuote;
}
// Verifies if a minion is alive
public boolean isAlive() {
if (this.getHP() > 0) {
return true;
} else {
return false;
}
}
// Method which plays a minion onto the field
public void play() {
System.out.println(this.getEntranceQuote());
}
// Method which makes a minion attack another minion
public void attack(Minion a) {
System.out.println(this.getAttackQuote());
a.changeHP(this.getAtt());
this.changeHP(a.getAtt());
if (!a.isAlive()) {
System.out.println(a.getDeathQuote());
}
if (!this.isAlive()) {
System.out.println(this.getDeathQuote());
}
}
// Changer method for hp
private void changeHP(int delta) {
hp -= delta;
}
// Main method
public static void main(String[] args) {
Minion patches = new Minion(1,1,"I'M IN CHARGE NOW","AYE AYE","SLURRRP");
Minion magmaRager = new Minion(5,1,"RAAUGH","RAUGH","RAUUUGH");
patches.play();
magmaRager.play();
patches.attack(magmaRager);
}
}