-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoom.java
50 lines (42 loc) · 1.06 KB
/
Room.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
public class Room {
private int roomNum;
private boolean vacant;
private Brother occupant = null;
public Room(int roomNum) {
this.roomNum = roomNum;
vacant = true;
}
public Room(int roomNum, Brother occupant) {
this.roomNum = roomNum;
this.occupant = occupant;
vacant = false;
}
public int getRoomNum() {
return roomNum;
}
public Brother getOccupant() {
return occupant;
}
public boolean getVacancyStatus() {
return vacant;
}
public void clearRoom() {
occupant = null;
vacant = true;
}
public void setOccupant(Brother newOccupant) {
occupant = newOccupant;
vacant = false;
}
public String toString() {
String s = "";
String occupantPhrase = "";
if (vacant) {
occupantPhrase = "vacant";
} else {
occupantPhrase = "occupied by " + occupant.getInitials();
}
s = "Room %d is %s";
return String.format(s, roomNum, occupantPhrase);
}
}