-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vehicle.java
64 lines (63 loc) · 1.33 KB
/
Vehicle.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
/*
* Created by Noah Shaw
*/
public class Vehicle {
//Attributes
private String manuName;
private int cylinders;
private String ownersName;
//Constructors
public Vehicle()
{
this.manuName = "";
this.cylinders = 0;
this.ownersName = "";
}
public Vehicle(String aManuName, int aCylinders, String aOwnersName)
{
this.setManuName(aManuName);
this.setCylinders(aCylinders);
this.setOwnersName(aOwnersName);
}
//Accessors
public String getManuName()
{
return this.manuName;
}
public int getCylinders()
{
return this.cylinders;
}
public String getOwnersName()
{
return this.ownersName;
}
//Mutators
public void setManuName(String aName)
{
this.manuName = aName;
}
public void setCylinders(int aCylinders)
{
if(aCylinders > 0)
{
this.cylinders = aCylinders;
}
}
public void setOwnersName(String aOwnersName)
{
this.ownersName = aOwnersName;
}
//Methods
public boolean equals(Vehicle aVehicle)
{
return aVehicle != null &&
this.manuName.equals(aVehicle.getManuName()) &&
this.cylinders == aVehicle.getCylinders() &&
this.ownersName.equals(aVehicle.getOwnersName());
}
public String toString()
{
return "Manufacturer's Name: "+this.manuName+"\nNumber of Cylinders: "+this.cylinders+"\nOwner's Name: "+this.ownersName;
}
}