forked from ramram43210/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarDemo.java
More file actions
37 lines (24 loc) · 730 Bytes
/
Copy pathCarDemo.java
File metadata and controls
37 lines (24 loc) · 730 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
public class CarDemo
{
public static void main(String[] args)
{
System.out
.println("Change Maruthi Alto K10 Car gear to 2 and increase the speed to 100");
Car maruthiAltok10 = new Car();
maruthiAltok10.changeGear(2);
maruthiAltok10.speedUp(100);
maruthiAltok10.printStates();
System.out.println("------------------------------");
System.out
.println("Change Swift Car gear to 3 and increase the speed to 200");
Car swift = new Car();
swift.changeGear(3);
swift.speedUp(200);
swift.printStates();
System.out
.println("Change Swift Car gear to 1 and apply break and decrease the speed from 200 to 150");
swift.changeGear(1);
swift.applyBrakes(50);
swift.printStates();
}
}