-
Notifications
You must be signed in to change notification settings - Fork 0
/
Alien2.java
77 lines (66 loc) · 1.3 KB
/
Alien2.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
public class Alien2 {
private int health, damage, type;
private final int
BORG = 1,
MARTIAN = 2,
DALEK = 3,
WOOKIE = 4,
CYLON = 5,
ALF = 6;
private final int
BORG_DAM = 10,
MARTIAN_DAM = 3,
DALEK_DAM = 12,
WOOKIE_DAM = 6,
CYLON_DAM = 2,
ALF_DAM = 60;
public Alien2(int h, int t) {
health = h;
type = t;
switch(type) {
case BORG: damage = BORG_DAM;
break;
case MARTIAN: damage = MARTIAN_DAM;
break;
case DALEK: damage = DALEK_DAM;
break;
case WOOKIE: damage = WOOKIE_DAM;
break;
case CYLON: damage = CYLON_DAM;
break;
case ALF: damage = ALF_DAM;
break;
}
}
public Alien2(Alien2 a) {
health = a.health;
type = a.type;
damage = a.damage;
}
public boolean isAlive() {
return health > 0;
}
public void takeDamage(int d) {
health -= d;
}
public int getDamage() {return damage;}
public int getHealth() {return health;}
public String toString() {
String s;
switch(type) {
case BORG: s = "Borg. ";
break;
case MARTIAN: s = "Martian. ";
break;
case DALEK: s = "Dalek. ";
break;
case WOOKIE: s = "Wookie. ";
break;
case CYLON: s = "Cylon. ";
break;
case ALF: s = "Alf. ";
break;
}
return s + "Health: " + health + ", Damage: " + damage + ".";
}
}