-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicle.java
More file actions
44 lines (36 loc) · 1022 Bytes
/
Vehicle.java
File metadata and controls
44 lines (36 loc) · 1022 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
public class Vehicle {
private String name;
private String size;
private int currentVelocity;
private int currentDirection;
public Vehicle(String name, String size) {
this.name = name;
this.size = size;
currentDirection=0;
currentVelocity=0;
}
public void steer(int direction){
this.currentDirection+=direction;
System.out.println("Vehicle.steer() "+currentDirection+"degrees");
}
public void move(int velocity, int direction){
currentDirection=direction;
currentVelocity=velocity;
System.out.println("Vehicle.move()"+currentVelocity+"in direction"+currentDirection);
}
public String getName() {
return name;
}
public String getSize() {
return size;
}
public int getCurrentVelocity() {
return currentVelocity;
}
public int getCurrentDirection() {
return currentDirection;
}
public void stop(){
this.currentVelocity=0;
}
}