-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoom.java
More file actions
56 lines (52 loc) · 1.39 KB
/
Room.java
File metadata and controls
56 lines (52 loc) · 1.39 KB
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
public class Room{
private int roomNumber;
private int daysRented;
private String roomType;
private String occupantName;
public Room(int roomNumber, String roomType){
this.roomNumber = roomNumber;
this.daysRented = 0;
this.occupantName = null;
if (roomType.equals("single king") || roomType.equals("double queen") ||roomType.equals("suite")){
this.roomType = roomType;
} else{
this.roomType = "double queen";
}
}
public int getRoomNumber(){
return roomNumber;
}
public int getDaysRented(){
return daysRented;
}
public String getRoomType(){
return roomType;
}
public String getOccupantName(){
return occupantName;
}
public boolean setOccupant(String name, int days){
if (this.occupantName != null){
return false;
}
occupantName = name;
daysRented = days;
return true;
}
public void advanceDay(){
daysRented--;
if (daysRented <= 0){
occupantName = null;
daysRented = 0;
}
}
public String toString(){
String roomStatus;
if (occupantName == null){
roomStatus = "free";
} else{
roomStatus = "rented";
}
return "Room " + roomNumber + ": " + roomType + " - " + roomStatus;
}
}