-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrewMember.java
More file actions
executable file
·48 lines (45 loc) · 857 Bytes
/
Copy pathCrewMember.java
File metadata and controls
executable file
·48 lines (45 loc) · 857 Bytes
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
class CrewMember {
private String name;
private int age, health;
occupation job;
public static enum occupation {
ENGINEER,
SCIENTIST,
COMMUNICATIONS_OFFICER,
PILOT,
CAPTAIN
}
public CrewMember(String name, int age, occupation job) {
this.name = name;
this.age = age;
this.job = job;
// Starting Health values. Based on age only.
if (age > 90) {
health = 20;
} else if (age > 65) {
health = 50;
} else if (age > 30) {
health = 95;
} else if (age > 18) {
health = 99;
} else { // aka, you a baby and more fragile.
health = 80;
}
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public occupation getOccupation() {
return job;
}
public int getHealth() {
return health;
}
public int changeHealth(int modVal) {
health = health + modVal;
return health;
}
}