-
Notifications
You must be signed in to change notification settings - Fork 0
/
Truck.java
58 lines (57 loc) · 1.12 KB
/
Truck.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 Truck extends Vehicle {
//Attributes
private double loadCap;
private double towCap;
//Constructors
public Truck()
{
super();
this.loadCap = 0;
this.towCap = 0;
}
public Truck(String aManuName, int aCylinders, String aOwnersName, double aLoadCap, double aTowCap)
{
super(aManuName, aCylinders, aOwnersName);
this.setLoadCap(aLoadCap);
this.setTowCap(aTowCap);
}
//Accessors
public double getLoadCap()
{
return this.loadCap;
}
public double getTowCap()
{
return this.towCap;
}
//Mutators
public void setLoadCap(double aLoadCap)
{
if(aLoadCap >= 0)
{
this.loadCap = aLoadCap;
}
}
public void setTowCap(double aTowCap)
{
if(aTowCap >= 0)
{
this.towCap = aTowCap;
}
}
//Methods
public boolean equals(Truck aTruck)
{
return aTruck != null &&
super.equals(aTruck) &&
this.loadCap == aTruck.getLoadCap() &&
this.towCap == aTruck.getTowCap();
}
public String toString()
{
return super.toString()+"\nLoad Capacity: "+this.loadCap+"\nTowing Capacity: "+this.towCap;
}
}