-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaff.java
More file actions
executable file
·43 lines (35 loc) · 1004 Bytes
/
Staff.java
File metadata and controls
executable file
·43 lines (35 loc) · 1004 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
package thinkinjava.test14;
import java.util.ArrayList;
public class Staff extends ArrayList<Position> {
public void add(String title, Person person) {
add(new Position(title, person));
}
public void add(String... titles) {
for (String title : titles) {
add(new Position(title));
}
}
public Staff(String... titles) {
add(titles);
}
public boolean positionAvailable(String title) {
for (Position position : this) {
if (position.getTitle().equals(title) && position.getPerson() == Person.NULL) {
return true;
}
}
return false;
}
public void fillPosition(String title, Person hire) {
for (Position position : this) {
if (position.getTitle().equals(title) && position.getPerson() == Person.NULL) {
position.setPerson(hire);
return;
}
}
throw new RuntimeException("Position " + title + " not available");
}
public static void main(String[] args) {
Staff staff = new Staff();
}
}