瀏覽代碼

Updated WriteIf methods

Trinh Tong 6 年之前
父節點
當前提交
d88b8bfb86
共有 2 個文件被更改,包括 23 次插入11 次删除
  1. 18
    6
      WriteIFs.java
  2. 5
    5
      package.bluej

+ 18
- 6
WriteIFs.java 查看文件

@@ -2,8 +2,8 @@
2 2
 /**
3 3
  * Write a description of class WriteIFs here.
4 4
  *
5
- * @author (your name)
6
- * @version (a version number or a date)
5
+ * @author Trinh Tong
6
+ * @version 10/18/18
7 7
  */
8 8
 public class WriteIFs
9 9
 {
@@ -11,6 +11,10 @@ public class WriteIFs
11 11
     public void playerDied(boolean player1) {
12 12
         // Write an IF statement that checks “player1.isAlive()” 
13 13
         // and if that’s false, calls “displayGameOver(player1)”
14
+        
15
+        if (player1 == false) {
16
+            displayGameOver(player1);
17
+        }
14 18
      
15 19
     }
16 20
     
@@ -18,9 +22,11 @@ public class WriteIFs
18 22
         // Write an IF statement that checks the 
19 23
         // “temperature(room)” and if that check is less than 70, 
20 24
         // calls “heatOn()” else calls “coolOn()”
21
-
22
-
23
-        
25
+        if (tempurature(room) < 70) {
26
+            heatOn();
27
+        } else {
28
+            coolOn();
29
+        }
24 30
         return this.ss;
25 31
     }
26 32
 
@@ -30,13 +36,19 @@ public class WriteIFs
30 36
         // AND 
31 37
         // “insideTemp()” is less than 62, 
32 38
         // calls “startAFire(fireplace1)”
39
+        
40
+        if (outsideTemp() < 50 && insideTemp() < 62) {
41
+            startAFire(fireplace1);
42
+        }
33 43
 
34 44
     }
35 45
 
36 46
     public void checkFuel(double fuelLevel) {
37 47
         // Write an IF statement that checks “fuelLevel” 
38 48
         // and if that check is less than 0.08, calls “refuel()”
39
-
49
+        if (fuelLevel < 0.08) {
50
+            refuel();
51
+        }
40 52
     }
41 53
 
42 54
 

+ 5
- 5
package.bluej 查看文件

@@ -9,14 +9,14 @@ editor.fx.0.height=722
9 9
 editor.fx.0.width=800
10 10
 editor.fx.0.x=560
11 11
 editor.fx.0.y=118
12
-objectbench.height=101
13
-objectbench.width=740
12
+objectbench.height=111
13
+objectbench.width=1241
14 14
 package.divider.horizontal=0.6
15
-package.divider.vertical=0.8625954198473282
16
-package.editor.height=671
15
+package.divider.vertical=0.8498727735368957
16
+package.editor.height=661
17 17
 package.editor.width=1139
18 18
 package.editor.x=112
19
-package.editor.y=89
19
+package.editor.y=56
20 20
 package.frame.height=844
21 21
 package.frame.width=1265
22 22
 package.numDependencies=2