-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hotel.java
30 lines (27 loc) · 994 Bytes
/
Hotel.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
public class Hotel {
private String name;
private ArrayList<Room> rooms;
public Hotel(String name, ArrayList<Room> rooms) {
this.name = name;
this.rooms = rooms;
}
public ArrayList<Room> getAvailableRooms(LocalDate checkInDate, LocalDate checkOutDate) {
ArrayList<Room> availableRooms = new ArrayList<Room>();
for (Room room : rooms) {
if (room.isAvailable()) {
availableRooms.add(room);
}
}
return availableRooms;
}
public Reservation reserveRoom(int roomNumber, Customer customer, LocalDate checkInDate, LocalDate checkOutDate) {
for (Room room : rooms) {
if (room.getRoomNumber() == roomNumber && room.isAvailable()) {
room.setAvailable(false);
Reservation reservation = new Reservation(room, customer, checkInDate, checkOutDate);
return reservation;
}
}
return null;
}
}