forked from WilliamHXu/BlueJ.FirstSaturday
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteIFs.java
More file actions
112 lines (96 loc) · 2.38 KB
/
WriteIFs.java
File metadata and controls
112 lines (96 loc) · 2.38 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
* Write a description of class WriteIFs here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class WriteIFs
{
public void playerDied(boolean player1) {
// Write an IF statement that checks “player1.isAlive()”
// and if that’s false, calls “displayGameOver(player1)”
if(!isAlive(player1)){
displayGameOver(player1);
}
}
public String thermoSTAT(int room) {
// Write an IF statement that checks the
// “temperature(room)” and if that check is less than 70,
// calls “heatOn()” else calls “coolOn()”
if(temperature(room) < 70){
heatOn();
} else {
coolOn();
}
return this.ss;
}
public void fireplaceControl(Object fireplace1) {
// Write an IF statement that checks
// “outsideTemp()” is less than 50
// AND
// “insideTemp()” is less than 62,
// calls “startAFire(fireplace1)”
if(outsideTemp() < 50 && insideTemp() < 62){
startAFire(fireplace1);
}
}
public void checkFuel(double fuelLevel) {
// Write an IF statement that checks “fuelLevel”
// and if that check is less than 0.08, calls “refuel()”
if(fuelLevel < .08){
refuel();
}
}
/**
* Pay no attention to the code below this point.
*
*
* instance variables
*/
int x;
int tt_t;
int tt_s;
int oo1, oo2;
String ss;
/**
* Constructor for objects of class WriteIFs
*/
public WriteIFs()
{
// initialise instance variables
x = 0;
tt_t = 0;
tt_s = 1;
ss = "";
oo1 = 61;
oo2 = 49;
}
// associated routines
public boolean isAlive(boolean p) {
return !p;
}
private int temperature(int t) {
return t+2;
}
private void heatOn() {
this.ss = "heating";
}
private void coolOn() {
this.ss = "cooling";
}
private int insideTemp() {
return oo1;
}
private int outsideTemp() {
return oo2;
}
private void startAFire(Object o) {
this.tt_s = 213;
}
private void refuel() {
this.x = 99;
}
private void displayGameOver(boolean b) {
this.ss = "Game Over!";
}
}