-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReservation.java
More file actions
48 lines (36 loc) · 1.09 KB
/
Copy pathReservation.java
File metadata and controls
48 lines (36 loc) · 1.09 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
public class Reservation {
String name;
int dayCount;
public Reservation(String name, int dayCount){
this.name = name;
this.dayCount = dayCount;
}
public Reservation(Reservation other){
this.name = other.name;
this.dayCount = other.dayCount;
}
public String getName(){
return name;
}
public void setName(String name) {
this.name = name;
}
public int getDayCount() {
return dayCount;
}
public void setDayCount(int dayCount) {
this.dayCount = dayCount;
}
@Override
public String toString() {
return "Reservation name: " + name + ", Day Count: " + dayCount;
}
public boolean equals(Reservation other){
return this.name.equals(other.name) && this.dayCount == other.dayCount ;
}
public Reservation extend(Reservation other){
String newName = this.name + " & " + other.name;
int newDayCount = this.dayCount + other.dayCount;
return new Reservation(newName , newDayCount);
}
}