Browse Source

updated ifs and while loops

Trinh Tong 6 years ago
parent
commit
d169f741dd
2 changed files with 15 additions and 8 deletions
  1. 9
    8
      WriteIFs.java
  2. 6
    0
      WriteIFsTest.java

+ 9
- 8
WriteIFs.java View File

@@ -1,4 +1,4 @@
1
-
1
+    
2 2
 /**
3 3
  * Write a description of class WriteIFs here.
4 4
  *
@@ -7,12 +7,17 @@
7 7
  */
8 8
 public class WriteIFs
9 9
 {
10
+    int x;
11
+   int tt_t;
12
+   int tt_s;
13
+   int oo1, oo2;
14
+   String ss;
10 15
  
11 16
     public void playerDied(boolean player1) {
12 17
         // Write an IF statement that checks “player1.isAlive()” 
13 18
         // and if that’s false, calls “displayGameOver(player1)”
14 19
         
15
-        if (player1 == false) {
20
+        if (isAlive(player1) == false) {
16 21
             displayGameOver(player1);
17 22
         }
18 23
      
@@ -37,7 +42,7 @@ public class WriteIFs
37 42
         // “insideTemp()” is less than 62, 
38 43
         // calls “startAFire(fireplace1)”
39 44
         
40
-        if (outsideTemp() < 50 && insideTemp() < 62) {
45
+        if (outsideTemp() < 50 || insideTemp() < 62) {
41 46
             startAFire(fireplace1);
42 47
         }
43 48
 
@@ -59,11 +64,7 @@ public class WriteIFs
59 64
      * 
60 65
      * instance variables
61 66
      * / 
62
-   int x;
63
-   int tt_t;
64
-   int tt_s;
65
-   int oo1, oo2;
66
-   String ss;
67
+
67 68
 
68 69
 
69 70
   /**

+ 6
- 0
WriteIFsTest.java View File

@@ -13,6 +13,12 @@ import org.junit.Test;
13 13
  */
14 14
 public class WriteIFsTest
15 15
 {
16
+    
17
+   int x;
18
+   int tt_t;
19
+   int tt_s;
20
+   int oo1, oo2;
21
+   String ss;
16 22
     private static final double _0_5 = 0.5;
17 23
     private static final double _0_04 = 0.04;
18 24