-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrip.java
More file actions
46 lines (37 loc) · 1.11 KB
/
Copy pathTrip.java
File metadata and controls
46 lines (37 loc) · 1.11 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
public class Trip {
private String destination;
private int days;
// constructor
public Trip(String destination, int days){
this.days = days;
this.destination = destination;
}
public Trip(Trip other){
this.days = other.days;
this.destination = other.destination;
}
public String getDestination(){
return destination;
}
public int getDays(){
return days;
}
public void setDays(int days) {
this.days = days;
}
public void setDestination(String destination) {
this.destination = destination;
}
@Override
public String toString() {
return " Trip to " + destination + " for " + days + " days. ";
}
public boolean equals(Trip other){
return this.destination.equals(other.destination) && this.days == other.days;
}
public Trip extend(Trip other){
String newDestination = this.destination + " & " + other.destination;
int newDays = this.days + other.days;
return new Trip(newDestination, newDays);
}
}