-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHotelReservation.java
More file actions
37 lines (23 loc) · 1.05 KB
/
Copy pathHotelReservation.java
File metadata and controls
37 lines (23 loc) · 1.05 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
public class HotelReservation extends Reservation {
private String roomType;
private boolean breakFastIncluded;
public HotelReservation(String name, int dayCount, String roomType, boolean breakFastIncluded ) {
super(name, dayCount);
this.roomType = roomType;
this.breakFastIncluded = breakFastIncluded;
}
public String toString(){
return super.toString() + "\n Room type: " + roomType +
"\n Breakfast Included: " + breakFastIncluded;
}
public boolean equals(HotelReservation other){
return super.equals(other) &&
this.roomType.equals(other.roomType) &&
this.breakFastIncluded == other.breakFastIncluded;
}
public HotelReservation extend (Reservation other) {
String newName = this.getName() + " & " + other.getName();
int newDayCount = this.getDayCount() + other.getDayCount();
return new HotelReservation(newName,newDayCount,this.roomType,this.breakFastIncluded);
}
}