-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReservation.java
More file actions
87 lines (67 loc) · 2.15 KB
/
Copy pathReservation.java
File metadata and controls
87 lines (67 loc) · 2.15 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package carbookingsystem1;
public class Reservation implements Payment {
private final int reservationID;
private String reservationStatus;
private Customer customer;
private Car car;
private int numperOfDayes;
public Reservation(Customer customer, Car car, int numperOfDayes) {
this.reservationID = MakeIdReservation();
setReservationStatus("New");
setCustomer(customer);
setCar(car);
setNumperOfDayes(numperOfDayes);
}
public Reservation() {
this(null, null, 0);
}
public String getReservationStatus() {
return reservationStatus;
}
public void setReservationStatus(String reservationStatus) {
this.reservationStatus = reservationStatus;
}
public int getReservationID() {
return reservationID;
}
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public Car getCar() {
return car;
}
public void setCar(Car car) {
this.car = car;
}
public int getNumperOfDayes() {
return numperOfDayes;
}
public void setNumperOfDayes(int numperOfDayes) {
this.numperOfDayes = numperOfDayes;
}
@Override
public String toString() {
return String.format("Reservation id %d %n Reservation Status %s %n Customer %s %n Car %s %n numperOfDayes %d %n", reservationID,
reservationStatus, customer, car,
numperOfDayes);
}
private final int MakeIdReservation() {
int min = 1;
int max = 1000;
int id = (int) (Math.random() * ((max - min) + 1)) + min;
return id;
}
public void cancelReservation() {
setReservationStatus("Cancelled");
System.out.println("Your booking has been cancelled .\n"
+ " Thank you!");
}
@Override
public double calculateAmount() {
double price = getNumperOfDayes() * car.calculateRentalPrice();
return ((price * INITAIL_FEE) + price);
}
}