-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCockpit.java
More file actions
78 lines (53 loc) · 1.39 KB
/
Cockpit.java
File metadata and controls
78 lines (53 loc) · 1.39 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
package semesterProject;
public class Cockpit {
Airplane plane;
Engine engine;
Navigation nav;
fuelTank tank;
Cockpit(Engine engine,Navigation nav ,fuelTank tank){
this.engine = engine;
this.nav = nav ;
this.tank = tank;
}
//Engine Saga Start
void runEngine() {
if (!engine.isRunning()) {
engine.startEngine();
}
}
void offEngine() {
if (engine.isRunning()) {
engine.offEngine();
nav.stopNav();
//off the thread
}
}
//Engine Saga End
void takeOff() {
if (!engine.isRunning()) {
runEngine();
System.out.println("Tighten Your Seatbelts We are taking off.......");
nav.startNav();
tank.startMeter();
}
}
void land() {
if (engine.isRunning()) {
offEngine();
nav.stopNav();
tank.stopMeter();
System.out.println("Landing...");
try {
Thread.sleep(3000);
} catch (InterruptedException e)
{
System.out.println("Landing process was interrupted.");
}
System.out.println("Reached "+nav.destination);
}
}
void displayMeter() {
tank.displayFuel();
}
}
//Start Thread Saga Flight Saga