|
@@ -7,20 +7,36 @@
|
7
|
7
|
*/
|
8
|
8
|
public class WriteIFs
|
9
|
9
|
{
|
10
|
|
-
|
|
10
|
+ int x;
|
|
11
|
+ int tt_t;
|
|
12
|
+ int tt_s;
|
|
13
|
+ int oo1, oo2;
|
|
14
|
+ String ss;
|
11
|
15
|
public void playerDied(boolean player1) {
|
12
|
16
|
// Write an IF statement that checks “player1.isAlive()”
|
13
|
17
|
// and if that’s false, calls “displayGameOver(player1)”
|
14
|
|
-
|
|
18
|
+ if(isAlive(true)){
|
|
19
|
+
|
|
20
|
+ }else{
|
|
21
|
+
|
|
22
|
+ displayGameOver(true);
|
|
23
|
+
|
|
24
|
+ }
|
|
25
|
+
|
15
|
26
|
}
|
16
|
|
-
|
|
27
|
+
|
17
|
28
|
public String thermoSTAT(int room) {
|
18
|
29
|
// Write an IF statement that checks the
|
19
|
30
|
// “temperature(room)” and if that check is less than 70,
|
20
|
31
|
// calls “heatOn()” else calls “coolOn()”
|
21
|
32
|
|
|
33
|
+ if(temperature(room) < 70) {
|
|
34
|
+ heatOn();
|
|
35
|
+ } else {
|
|
36
|
+ coolOn();
|
22
|
37
|
|
23
|
38
|
|
|
39
|
+ }
|
24
|
40
|
return this.ss;
|
25
|
41
|
}
|
26
|
42
|
|
|
@@ -30,70 +46,68 @@ public class WriteIFs
|
30
|
46
|
// AND
|
31
|
47
|
// “insideTemp()” is less than 62,
|
32
|
48
|
// calls “startAFire(fireplace1)”
|
|
49
|
+ if(outsideTemp() < 50 && insideTemp() > 62) {
|
|
50
|
+ startAFire(fireplace1);
|
33
|
51
|
|
|
52
|
+ }
|
34
|
53
|
}
|
35
|
54
|
|
36
|
55
|
public void checkFuel(double fuelLevel) {
|
37
|
56
|
// Write an IF statement that checks “fuelLevel”
|
38
|
57
|
// and if that check is less than 0.08, calls “refuel()”
|
|
58
|
+ if(fuelLevel < 0.08){
|
|
59
|
+ refuel();
|
|
60
|
+
|
39
|
61
|
|
40
|
62
|
}
|
|
63
|
+}
|
41
|
64
|
|
|
65
|
+
|
42
|
66
|
|
43
|
|
-
|
44
|
|
- /**
|
45
|
|
- * Pay no attention to the code below this point.
|
46
|
|
- *
|
47
|
|
- *
|
48
|
|
- * instance variables
|
49
|
|
- * /
|
50
|
|
- int x;
|
51
|
|
- int tt_t;
|
52
|
|
- int tt_s;
|
53
|
|
- int oo1, oo2;
|
54
|
|
- String ss;
|
55
|
|
-
|
56
|
|
-
|
57
|
|
- /**
|
58
|
|
- * Constructor for objects of class WriteIFs
|
59
|
|
- */
|
60
|
|
- public WriteIFs()
|
61
|
|
- {
|
62
|
|
- // initialise instance variables
|
63
|
|
- x = 0;
|
64
|
|
- tt_t = 0;
|
65
|
|
- tt_s = 1;
|
66
|
|
- ss = "";
|
67
|
|
- oo1 = 61;
|
68
|
|
- oo2 = 49;
|
69
|
|
- }
|
|
67
|
+ public WriteIFs()
|
|
68
|
+ {
|
|
69
|
+ // initialise instance variables
|
|
70
|
+ x = 0;
|
|
71
|
+ tt_t = 0;
|
|
72
|
+ tt_s = 1;
|
|
73
|
+ ss = "";
|
|
74
|
+ oo1 = 61;
|
|
75
|
+ oo2 = 49;
|
|
76
|
+ }
|
70
|
77
|
|
71
|
78
|
// associated routines
|
72
|
79
|
public boolean isAlive(boolean p) {
|
73
|
80
|
return !p;
|
74
|
81
|
}
|
75
|
|
- private int tempurature(int t) {
|
|
82
|
+
|
|
83
|
+ private int temperature(int t) {
|
76
|
84
|
return t+2;
|
77
|
85
|
}
|
|
86
|
+
|
78
|
87
|
private void heatOn() {
|
79
|
88
|
this.ss = "heating";
|
80
|
89
|
}
|
|
90
|
+
|
81
|
91
|
private void coolOn() {
|
82
|
92
|
this.ss = "cooling";
|
83
|
93
|
}
|
84
|
|
-
|
|
94
|
+
|
85
|
95
|
private int insideTemp() {
|
86
|
96
|
return oo1;
|
87
|
97
|
}
|
|
98
|
+
|
88
|
99
|
private int outsideTemp() {
|
89
|
100
|
return oo2;
|
90
|
101
|
}
|
|
102
|
+
|
91
|
103
|
private void startAFire(Object o) {
|
92
|
|
- this.tt_s = 213;
|
|
104
|
+ this.tt_s = 1;
|
93
|
105
|
}
|
|
106
|
+
|
94
|
107
|
private void refuel() {
|
95
|
108
|
this.x = 99;
|
96
|
109
|
}
|
|
110
|
+
|
97
|
111
|
private void displayGameOver(boolean b) {
|
98
|
112
|
this.ss = "Game Over!";
|
99
|
113
|
}
|