-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCar.java
58 lines (57 loc) · 1.14 KB
/
Car.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
/*
* Created by Noah Shaw
*/
public class Car extends Vehicle {
//Attributes
private double mileage;
private int passengers;
//Constructors
public Car()
{
super();
this.mileage = 0.0;
this.passengers = 0;
}
public Car(String aManuName, int aCylinders, String aOwnersName, double aMileage, int aPassengers)
{
super(aManuName, aCylinders, aOwnersName);
this.setMileage(aMileage);
this.setPassengers(aPassengers);
}
//Accessors
public double getMileage()
{
return this.mileage;
}
public double getPassengers()
{
return this.passengers;
}
//Mutators
public void setMileage(double aMileage)
{
if(aMileage >= 0)
{
this.mileage = aMileage;
}
}
public void setPassengers(int aPassengers)
{
if(aPassengers >= 0)
{
this.passengers = aPassengers;
}
}
//Methods
public boolean equals(Car aCar)
{
return aCar != null &&
super.equals(aCar) &&
this.mileage == aCar.getMileage() &&
this.passengers == aCar.getPassengers();
}
public String toString()
{
return super.toString()+"\nMileage: "+this.mileage+"\nPassengers: "+this.passengers;
}
}