-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathVehicle.java
More file actions
154 lines (133 loc) · 2.22 KB
/
Vehicle.java
File metadata and controls
154 lines (133 loc) · 2.22 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/**
* A Vehicle.
* @author Brian
*
*/
public class Vehicle
{
//VIN
private String vin;
//MAKE
private String make;
//MODEL
private String model;
//YEAR
private int year;
//COLOR
private String color;
//Mileage
private double mileage;
private boolean isRunning;
private double speed;
private double bearing;
public Vehicle() {
//do nothing
}
public Vehicle(String startVin, String startMake, String startModel, int startYear, String startColor, double startMileage)
{
vin = startVin;
make = startMake;
model = startModel;
year = startYear;
color = startColor;
mileage = startMileage;
speed = 0.0;
}
//
public String getVin()
{
return vin;
}
public void setVin(String value)
{
vin = value;
}
//make
public String getMake()
{
return make;
}
public void setMake(String value)
{
make = value;
}
//model
public String getModel()
{
return model;
}
public void setModel(String value)
{
model = value;
}
//year
public int getYear()
{
return year;
}
public void setYear(int value)
{
year = value;
}
//color
public String getColor()
{
return color;
}
public void setColor(String value)
{
color = value;
}
//mileage
public double getMileage()
{
return mileage;
}
public void setMileage(double value)
{
mileage = value;
}
public void start()
{
isRunning = true;
}
public void stop()
{
isRunning = false;
}
public boolean isRunning()
{
return isRunning;
}
public double getSpeed()
{
return speed;
}
public double accellerate()
{
speed += .5;
return this.getSpeed();
}
public double accellerate(double value)
{
speed += value;
return this.getSpeed();
}
public void changeDirection(double value)
{
bearing = value;
}
public double getDirection()
{
return bearing;
}
public String toString() {
return String.format("VIN: %s\tMake: %s\tModel: %s\tYear: %d\tColor: %s\tMileage: %.1f"
, this.getVin()
, this.getMake()
, this.getModel()
, this.getYear()
, this.getColor()
, this.getMileage());
}
}