-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWheel.java
More file actions
58 lines (55 loc) · 985 Bytes
/
Copy pathWheel.java
File metadata and controls
58 lines (55 loc) · 985 Bytes
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
/*
* Jiarong Xu
*/
public class Wheel {
//instance variables
private double diameter;
private double width;
//default constructors
public Wheel()
{
this.diameter = 16.0;
this.width = 1.0;
}
//parameterized
public Wheel(double aD, double aW)
{
this.setDiameter(aD);
this.setWidth(aW);
}
//getter
public double getDiameter()
{
return this.diameter;
}
public double getWidth()
{
return this.width;
}
//setter
public void setDiameter(double aD)
{
if (aD >=16 && aD <= 55)
this.diameter = aD;
else
this.diameter = 16;
}
public void setWidth(double aW)
{
if (aW >= 1 && aW <= 2.5)
this.width = aW;
else
this.width = 1;
}
// more methods
public boolean equals(Wheel a)
{
return a != null &&
a.getDiameter() == this.diameter &&
a.getWidth() == this.width;
}
public String toString()
{
return "[Wheel] Diameter "+this.diameter+" Width: "+this.width;
}
}