-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
63 lines (53 loc) · 2.3 KB
/
Main.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
package eu.rideg;
public class Main {
public static void main(String[] args) {
// TIM BUCHALKA'S JAVA MASTERCLASS CHALLENGE START
//
// This is a challenge, defined by Tim Buchalka
// This comment part of the code is a part of his Complete Java Master Course from www.udemy.com:
//
// https://www.udemy.com/java-the-complete-java-developer-course/
//
// I share the challenge text with his permission.
//
// START OF CHALLENGE FOR INHERITANCE
//
// Challenge.
// Start with a base class of a Vehicle, then create a Car class that inherits from this base class.
// Finally, create another class, a specific type of Car that inherits from the Car class.
// You should be able to hand steering, changing gears, and moving (speed in other words).
// You will want to decide where to put the appropriate state and behaviours (fields and methods).
// As mentioned above, changing gears, increasing/decreasing speed should be included.
// For you specific type of vehicle you will want to add something specific for that type of car.
//
// END OF CHALLENGE FOR INHERITANCE
//
// https://www.udemy.com/java-the-complete-java-developer-course/
//
// The code with the solution is made by myself.
Car newCar = new Car("A3", "TFSI", 2.0,6,0,0);
newCar.changeGear(4);
newCar.changeGear(7);
newCar.changeGear(-1);
newCar.changeGear(4);
newCar.steering(30);
newCar.steering(15);
newCar.steering(-370);
newCar.steering(361);
newCar.changeSpeed(120);
newCar.changeSpeed(-50);
newCar.brake();
newCar.brake();
System.out.println("");
DeLorean DeLoreanDMC12 = new DeLorean("DMC-12","nuclear",10,10,0,0,2015, false);
DeLoreanDMC12.timeTravel(2015);
DeLoreanDMC12.timeTravel(2018);
DeLoreanDMC12.changeSpeed(250);
DeLoreanDMC12.changeGear(5);
DeLoreanDMC12.doorElevation(true);
DeLoreanDMC12.doorElevation(true);
DeLoreanDMC12.doorElevation(false);
DeLoreanDMC12.doorElevation(false);
DeLoreanDMC12.brake();
}
}