Kr Younger 6 jaren geleden
bovenliggende
commit
998c7fd031
3 gewijzigde bestanden met toevoegingen van 66 en 31 verwijderingen
  1. 10
    5
      WriteIFs.java
  2. 33
    6
      WriteIFsTest.java
  3. 23
    20
      package.bluej

+ 10
- 5
WriteIFs.java Bestand weergeven

@@ -25,9 +25,11 @@ public class WriteIFs
25 25
     }
26 26
 
27 27
     public void fireplaceControl(Object fireplace1) {
28
-        // Write an IF statement that checks “outsideTemp()” 
29
-        // is less than 50 AND “insideTemp()” 
30
-        // is less than 62, calls “startAFire(fireplace1)”
28
+        // Write an IF statement that checks 
29
+        // “outsideTemp()” is less than 50 
30
+        // AND 
31
+        // “insideTemp()” is less than 62, 
32
+        // calls “startAFire(fireplace1)”
31 33
 
32 34
     }
33 35
 
@@ -41,6 +43,7 @@ public class WriteIFs
41 43
    int x;
42 44
    int tt_t;
43 45
    int tt_s;
46
+   int oo1, oo2;
44 47
    String ss;
45 48
 
46 49
 
@@ -54,6 +57,8 @@ public class WriteIFs
54 57
       tt_t = 0;
55 58
       tt_s = 1;
56 59
       ss = "";
60
+      oo1 = 61;
61
+      oo2 = 49;
57 62
   }
58 63
 
59 64
     // associated routines
@@ -71,10 +76,10 @@ public class WriteIFs
71 76
     }
72 77
  
73 78
     private int insideTemp() {
74
-        return 61;
79
+        return oo1;
75 80
     }
76 81
     private int outsideTemp() {
77
-        return 49;
82
+        return oo2;
78 83
     }
79 84
     private void startAFire(Object o) {
80 85
         this.tt_s = 213;

+ 33
- 6
WriteIFsTest.java Bestand weergeven

@@ -65,21 +65,48 @@ public class WriteIFsTest
65 65
         assertEquals("cooling", writeIFs1.thermoSTAT(81));
66 66
     }
67 67
     @Test
68
-    public void TestCheckFuel()
68
+    public void TestCheckFuel1()
69 69
     {
70 70
         WriteIFs writeIFs1 = new WriteIFs();
71
-        writeIFs1.playerDied(true);
72
-        assertEquals("Game Over!", writeIFs1.ss);
71
+        writeIFs1.checkFuel(_0_5);
72
+        assertEquals(0, writeIFs1.x);
73 73
     }
74 74
     @Test
75
-    public void TestFireControl()
75
+    public void TestCheckFuel2()
76 76
     {
77 77
         WriteIFs writeIFs1 = new WriteIFs();
78
-        writeIFs1.checkFuel(_0_5);
79
-        assertEquals(0, writeIFs1.x);
80 78
         writeIFs1.checkFuel(_0_04);
81 79
         assertEquals(99, writeIFs1.x);
82 80
     }
81
+    @Test
82
+    public void TestFireControl()
83
+    {
84
+        WriteIFs writeIFs1 = new WriteIFs();
85
+        Object oo = new Object();
86
+        writeIFs1.tt_s = 1;
87
+        writeIFs1.fireplaceControl(oo);
88
+        assertEquals(213, writeIFs1.tt_s);
89
+    }
90
+    @Test
91
+    public void TestFireControl2()
92
+    {
93
+        WriteIFs writeIFs1 = new WriteIFs();
94
+        Object oo = new Object();
95
+        writeIFs1.oo1 = 65;
96
+        writeIFs1.tt_s = 1;
97
+        writeIFs1.fireplaceControl(oo);
98
+        assertEquals(213, writeIFs1.tt_s);
99
+    }
100
+    @Test
101
+    public void TestFireControl3()
102
+    {
103
+        WriteIFs writeIFs1 = new WriteIFs();
104
+        Object oo = new Object();
105
+        writeIFs1.oo2 = 80;
106
+        writeIFs1.tt_s = 1;
107
+        writeIFs1.fireplaceControl(oo);
108
+        assertEquals(213, writeIFs1.tt_s);
109
+    }
83 110
 
84 111
 }
85 112
 

+ 23
- 20
package.bluej Bestand weergeven

@@ -1,14 +1,17 @@
1 1
 #BlueJ package file
2
-dependency1.from=WriteIFsTest
3
-dependency1.to=WriteIFs
2
+dependency1.from=WriteLoopsTest
3
+dependency1.to=WriteLoops
4 4
 dependency1.type=UsesDependency
5
+dependency2.from=WriteIFsTest
6
+dependency2.to=WriteIFs
7
+dependency2.type=UsesDependency
5 8
 editor.fx.0.height=722
6 9
 editor.fx.0.width=800
7
-editor.fx.0.x=90
8
-editor.fx.0.y=152
10
+editor.fx.0.x=560
11
+editor.fx.0.y=118
9 12
 objectbench.height=101
10
-objectbench.width=694
11
-package.divider.horizontal=0.5630522088353414
13
+objectbench.width=740
14
+package.divider.horizontal=0.6
12 15
 package.divider.vertical=0.8625954198473282
13 16
 package.editor.height=671
14 17
 package.editor.width=1139
@@ -16,7 +19,7 @@ package.editor.x=112
16 19
 package.editor.y=89
17 20
 package.frame.height=844
18 21
 package.frame.width=1265
19
-package.numDependencies=1
22
+package.numDependencies=2
20 23
 package.numTargets=4
21 24
 package.showExtends=true
22 25
 package.showUses=true
@@ -30,7 +33,7 @@ target1.height=110
30 33
 target1.name=WriteLoopsTest
31 34
 target1.showInterface=false
32 35
 target1.type=UnitTestTargetJunit4
33
-target1.width=180
36
+target1.width=100
34 37
 target1.x=170
35 38
 target1.y=330
36 39
 target2.association=WriteLoopsTest
@@ -38,21 +41,21 @@ target2.height=110
38 41
 target2.name=WriteLoops
39 42
 target2.showInterface=false
40 43
 target2.type=ClassTarget
41
-target2.width=180
44
+target2.width=100
42 45
 target2.x=140
43 46
 target2.y=360
44
-target3.association=WriteIFsTest
45 47
 target3.height=110
46
-target3.name=WriteIFs
48
+target3.name=WriteIFsTest
47 49
 target3.showInterface=false
48
-target3.type=ClassTarget
49
-target3.width=170
50
-target3.x=150
51
-target3.y=130
50
+target3.type=UnitTestTargetJunit4
51
+target3.width=80
52
+target3.x=180
53
+target3.y=100
54
+target4.association=WriteIFsTest
52 55
 target4.height=110
53
-target4.name=WriteIFsTest
56
+target4.name=WriteIFs
54 57
 target4.showInterface=false
55
-target4.type=UnitTestTargetJunit4
56
-target4.width=170
57
-target4.x=180
58
-target4.y=100
58
+target4.type=ClassTarget
59
+target4.width=80
60
+target4.x=150
61
+target4.y=130