-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTravelPacket.java
49 lines (45 loc) · 1.67 KB
/
TravelPacket.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
37
38
39
40
41
42
43
44
45
46
47
48
49
public class TravelPacket {
// Object attributes
private String packetID = "";
private String destination = "";
private String date = "";
private int duration = 0;
private float price = 0;
// Set methods
public void setPacketID(String packetID){this.packetID = packetID;}
public void setDestination(String destination){this.destination= destination;}
public void setDatum(String date){this.date = date;}
public void setDuration(int duration){this.duration = duration;}
public void setPrice(float price){this.price = price;}
//Get methods
public String getPacketID(){return this.packetID;}
public String getDestination(){return this.destination;}
public String getDatum(){return this.date;}
public int getDuration(){return this.duration;}
public float getPrice(){return this.price;}
// Overrides
@Override
public String toString() {
return "ID: " + getPacketID() + ", Destination: " +
getDestination() + ", Datum: " +
getDatum() + ", Dauer: " +
getDuration() + ", Preis: " + getPrice();
}
@Override
public boolean equals(Object obj) {
if (obj instanceof TravelPacket travel_packet){
return getPacketID().equals(travel_packet.getPacketID());
} return false;
}
// Constructors
public TravelPacket(String packetID){
this.packetID= packetID;
}
public TravelPacket(String packetID, String destination, String date, int duration, float price){
this(packetID);
this.destination = destination;
this.date = date;
this.duration = duration;
this.price = price;
}
}