-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaxi.java
79 lines (71 loc) · 2.18 KB
/
Taxi.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
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
public class Taxi extends Automobile {
private Person driver;
private String ID;
/**
* Constructor for the Taxi class
* @param owner the owner of the Taxi as a Person
* @param make the make of the Taxi in String
* @param model the model of the Taxi in String
* @param year the year of the Taxi in int
* @param mileage the mileage of the Taxi in int
* @param numPassengers the number of passengers of the Taxi in int
* @param isSUV whether or not the Taxi is an SUV in boolean
* @param driver the driver of the Taxi as a Person
* @param ID the ID of the driver in String
*/
public Taxi(Person owner, String make, String model, int year, int mileage, int numPassengers, boolean isSUV, Person driver, String ID) {
super(owner, make, model, year, mileage, numPassengers, isSUV);
this.driver = driver;
this.ID = ID;
}
/**
* Getter for driver
* @return a Person driver
*/
public Person getDriver() {
return this.driver;
}
/**
* Getter for ID
* @return a String ID
*/
public String getID() {
return this.ID;
}
/**
* Setter for driver
* @param driver driver of the Taxi in Person
*/
public void setDriver(Person driver) {
this.driver = driver;
}
/**
* Setter for ID
* @param ID ID of the Taxi in String
*/
public void setID(String ID) {
this.ID = ID;
}
@Override
/**
* Overridden toString() method for Taxi
* @return a String containing formatted output
*/
public String toString() {
return String.format("%s\nDriver: %s ID#%s", super.toString(), this.getDriver(), this.getID());
}
@Override
/**
* Overridden equals() method for Taxi
* @return true if all fields are the same, false otherwise
*/
public boolean equals(Object o) {
if (o.getClass() != this.getClass())
return false;
Taxi t = (Taxi) o;
if (super.equals(o) && this.getDriver().equals(t.getDriver()) && this.getID().equals(t.getID()))
return true;
else
return false;
}
}