-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reservation.java
36 lines (30 loc) · 973 Bytes
/
Reservation.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
public class Reservation {
private Room room;
private Customer customer;
private LocalDate checkInDate;
private LocalDate checkOutDate;
public Reservation(Room room, Customer customer, LocalDate checkInDate, LocalDate checkOutDate) {
this.room = room;
this.customer = customer;
this.checkInDate = checkInDate;
this.checkOutDate = checkOutDate;
}
public Room getRoom() {
return room;
}
public Customer getCustomer() {
return customer;
}
public LocalDate getCheckInDate() {
return checkInDate;
}
public LocalDate getCheckOutDate() {
return checkOutDate;
}
public double getTotalCost() {
// Calculate the number of days in the reservation
int numDays = (int) (checkOutDate.toEpochDay() - checkInDate.toEpochDay());
// Calculate and return the total cost of the reservation
return numDays * room.getPrice();
}
}