Kr Younger 6 years ago
parent
commit
998c7fd031
3 changed files with 66 additions and 31 deletions
  1. 10
    5
      WriteIFs.java
  2. 33
    6
      WriteIFsTest.java
  3. 23
    20
      package.bluej

+ 10
- 5
WriteIFs.java View File

25
     }
25
     }
26
 
26
 
27
     public void fireplaceControl(Object fireplace1) {
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
    int x;
43
    int x;
42
    int tt_t;
44
    int tt_t;
43
    int tt_s;
45
    int tt_s;
46
+   int oo1, oo2;
44
    String ss;
47
    String ss;
45
 
48
 
46
 
49
 
54
       tt_t = 0;
57
       tt_t = 0;
55
       tt_s = 1;
58
       tt_s = 1;
56
       ss = "";
59
       ss = "";
60
+      oo1 = 61;
61
+      oo2 = 49;
57
   }
62
   }
58
 
63
 
59
     // associated routines
64
     // associated routines
71
     }
76
     }
72
  
77
  
73
     private int insideTemp() {
78
     private int insideTemp() {
74
-        return 61;
79
+        return oo1;
75
     }
80
     }
76
     private int outsideTemp() {
81
     private int outsideTemp() {
77
-        return 49;
82
+        return oo2;
78
     }
83
     }
79
     private void startAFire(Object o) {
84
     private void startAFire(Object o) {
80
         this.tt_s = 213;
85
         this.tt_s = 213;

+ 33
- 6
WriteIFsTest.java View File

65
         assertEquals("cooling", writeIFs1.thermoSTAT(81));
65
         assertEquals("cooling", writeIFs1.thermoSTAT(81));
66
     }
66
     }
67
     @Test
67
     @Test
68
-    public void TestCheckFuel()
68
+    public void TestCheckFuel1()
69
     {
69
     {
70
         WriteIFs writeIFs1 = new WriteIFs();
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
     @Test
74
     @Test
75
-    public void TestFireControl()
75
+    public void TestCheckFuel2()
76
     {
76
     {
77
         WriteIFs writeIFs1 = new WriteIFs();
77
         WriteIFs writeIFs1 = new WriteIFs();
78
-        writeIFs1.checkFuel(_0_5);
79
-        assertEquals(0, writeIFs1.x);
80
         writeIFs1.checkFuel(_0_04);
78
         writeIFs1.checkFuel(_0_04);
81
         assertEquals(99, writeIFs1.x);
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 View File

1
 #BlueJ package file
1
 #BlueJ package file
2
-dependency1.from=WriteIFsTest
3
-dependency1.to=WriteIFs
2
+dependency1.from=WriteLoopsTest
3
+dependency1.to=WriteLoops
4
 dependency1.type=UsesDependency
4
 dependency1.type=UsesDependency
5
+dependency2.from=WriteIFsTest
6
+dependency2.to=WriteIFs
7
+dependency2.type=UsesDependency
5
 editor.fx.0.height=722
8
 editor.fx.0.height=722
6
 editor.fx.0.width=800
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
 objectbench.height=101
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
 package.divider.vertical=0.8625954198473282
15
 package.divider.vertical=0.8625954198473282
13
 package.editor.height=671
16
 package.editor.height=671
14
 package.editor.width=1139
17
 package.editor.width=1139
16
 package.editor.y=89
19
 package.editor.y=89
17
 package.frame.height=844
20
 package.frame.height=844
18
 package.frame.width=1265
21
 package.frame.width=1265
19
-package.numDependencies=1
22
+package.numDependencies=2
20
 package.numTargets=4
23
 package.numTargets=4
21
 package.showExtends=true
24
 package.showExtends=true
22
 package.showUses=true
25
 package.showUses=true
30
 target1.name=WriteLoopsTest
33
 target1.name=WriteLoopsTest
31
 target1.showInterface=false
34
 target1.showInterface=false
32
 target1.type=UnitTestTargetJunit4
35
 target1.type=UnitTestTargetJunit4
33
-target1.width=180
36
+target1.width=100
34
 target1.x=170
37
 target1.x=170
35
 target1.y=330
38
 target1.y=330
36
 target2.association=WriteLoopsTest
39
 target2.association=WriteLoopsTest
38
 target2.name=WriteLoops
41
 target2.name=WriteLoops
39
 target2.showInterface=false
42
 target2.showInterface=false
40
 target2.type=ClassTarget
43
 target2.type=ClassTarget
41
-target2.width=180
44
+target2.width=100
42
 target2.x=140
45
 target2.x=140
43
 target2.y=360
46
 target2.y=360
44
-target3.association=WriteIFsTest
45
 target3.height=110
47
 target3.height=110
46
-target3.name=WriteIFs
48
+target3.name=WriteIFsTest
47
 target3.showInterface=false
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
 target4.height=110
55
 target4.height=110
53
-target4.name=WriteIFsTest
56
+target4.name=WriteIFs
54
 target4.showInterface=false
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