#37 Curtis Cook

オープン
CurtisMCook が 1 個のコミットを CurtisMCook/FirstSaturday:master から master へマージしようとしています
共有4 個のファイルを変更した119 個の追加38 個の削除を含む
  1. 19
    5
      WriteIFs.java
  2. 86
    19
      WriteLoops.java
  3. 1
    1
      WriteLoopsTest.java
  4. 13
    13
      package.bluej

+ 19
- 5
WriteIFs.java ファイルの表示

@@ -7,19 +7,29 @@
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
+        if(!isAlive(player1)) {
20
+            displayGameOver(player1);
21
+        }     
15 22
     }
16 23
     
17 24
     public String thermoSTAT(int room) {
18 25
         // Write an IF statement that checks the 
19 26
         // “temperature(room)” and if that check is less than 70, 
20 27
         // calls “heatOn()” else calls “coolOn()”
21
-
22
-
28
+        if(room < 70) {
29
+            heatOn();
30
+        } else {
31
+            coolOn();
32
+        }
23 33
         
24 34
         return this.ss;
25 35
     }
@@ -30,13 +40,17 @@ public class WriteIFs
30 40
         // AND 
31 41
         // “insideTemp()” is less than 62, 
32 42
         // calls “startAFire(fireplace1)”
33
-
43
+        if(outsideTemp() < 50 || insideTemp() < 62) {
44
+            startAFire(fireplace1);
45
+        }
34 46
     }
35 47
 
36 48
     public void checkFuel(double fuelLevel) {
37 49
         // Write an IF statement that checks “fuelLevel” 
38 50
         // and if that check is less than 0.08, calls “refuel()”
39
-
51
+        if(fuelLevel < 0.08) {
52
+            refuel();
53
+        }
40 54
     }
41 55
 
42 56
 

+ 86
- 19
WriteLoops.java ファイルの表示

@@ -20,10 +20,15 @@ public class WriteLoops {
20 20
 
21 21
         // Write a FOR loop that counts from 1 to 10.
22 22
             // calling
23
-            w = w + 1;
23
+            // w = w + 1;
24 24
             // each time through the loop
25 25
 
26 26
         // this will tell the test how many times the loop executed.
27
+        
28
+        for(int i = 0; i < 5; i++) {
29
+            w += 1;
30
+        }
31
+
27 32
         return w;
28 33
     }
29 34
 
@@ -32,9 +37,13 @@ public class WriteLoops {
32 37
 
33 38
         // Write a FOR loop that counts from 1 to 10.
34 39
         // calling
35
-        w = w + 1;
40
+        // w = w + 1;
36 41
         // each time through the loop
37 42
         
43
+        for(int i = 0; i < 10; i++) {
44
+            w += 1;
45
+        }
46
+        
38 47
         return w;
39 48
     }
40 49
 
@@ -43,9 +52,13 @@ public class WriteLoops {
43 52
 
44 53
         // Write a FOR loop that makes 10 iterations, start at 21.
45 54
         // calling
46
-        w = w + 1;
55
+        // w = w + 1;
47 56
         // each time through the loop
48 57
         
58
+        for(int i = 21; i <= 31; i++) {
59
+            w += 1;
60
+        }
61
+        
49 62
         return w;
50 63
     }
51 64
 
@@ -54,8 +67,11 @@ public class WriteLoops {
54 67
 
55 68
         // Write a FOR loop that counts down from 100 to 0.
56 69
         // calling
57
-        w = w + 1;
70
+        // w = w + 1;
58 71
         // each time through the loop
72
+        for(int i = 100; i > 0; i--) {
73
+            w += 1;
74
+        }
59 75
         
60 76
         return w;
61 77
     }
@@ -65,8 +81,12 @@ public class WriteLoops {
65 81
 
66 82
         // Write a FOR loop from 0 to 32 by 2s.
67 83
         // calling
68
-        w = w + 1;
84
+        // w = w + 1;
69 85
         // each time through the loop
86
+        for(int i = 0; i < 32; i += 2) {
87
+            w += 1;
88
+        }
89
+        
70 90
         return w;
71 91
     }
72 92
 
@@ -75,9 +95,13 @@ public class WriteLoops {
75 95
 
76 96
         // Write a FOR loop from 1 to less than 5001 by 11s.
77 97
         // calling
78
-        w = w + 1;
98
+        // w = w + 1;
79 99
         // each time through the loop
80
-        
100
+
101
+        for(int i = 1; i < 5001; i += 11) {
102
+            w += 1;
103
+        }
104
+       
81 105
         return w;
82 106
     }
83 107
 
@@ -87,8 +111,17 @@ public class WriteLoops {
87 111
         // Write a nested FOR loop(s), where one counts from
88 112
         // 0 to less than 20 and the inner one counts from 0 to 4
89 113
                 // calling
90
-                w = w + 1;
114
+                // w = w + 1;
91 115
                 // each time through the inner loop
116
+                
117
+                
118
+
119
+      for(int i = 0; i < 20; i++) {
120
+          for(int j = 0; j <= 4; j++) {
121
+              w += 1;
122
+            }
123
+        }
124
+                
92 125
 
93 126
         return w;
94 127
     }
@@ -102,9 +135,16 @@ public class WriteLoops {
102 135
         // prints “Hello Zipcode” instead of the statement w = w + 1;
103 136
 
104 137
                 // calling
105
-                w = w + 1;
138
+                // w = w + 1;
106 139
             // each time through the inner loop
107 140
         
141
+            
142
+            for(int i = 5; i < 105; i++) {
143
+                if(i <= 51) {
144
+                    System.out.println("Hello Zipcode");
145
+                    w += 1;
146
+                }
147
+            }
108 148
         return w;
109 149
     }
110 150
 
@@ -113,17 +153,19 @@ public class WriteLoops {
113 153
 
114 154
         // sample while loop
115 155
         while (i <= 5) {
116
-            System.out.println("Eww.");
117
-            i = i + 1;
156
+            System.out.println("Eww."); // 0, 1, 2, 3, 4, 5
157
+            i = i + 1; // 1, 2, 3, 4, 5, 6
118 158
         }
119 159
 
120 160
         // sample do...while loop
121 161
         i = 8;
122 162
         do {
123
-            System.out.println("Eww.");
124
-            i = i - 1;
163
+            System.out.println("Eww."); // 8, 7, 6, 5, 4, 3, 2, 1
164
+            i = i - 1;// 7, 6, 5, 4, 3, 2, 1, 0
125 165
         } while (i > 0);
126 166
         // what's the primary difference between them?!?
167
+        // The condition is checked at the begining for the while loop and at the end of the do while
168
+        // loop.  This guarantees that the do while loop will be run at least once.
127 169
     }
128 170
 
129 171
     // Write a WHILE loop that checks “gpsCurrentLocation()”
@@ -135,9 +177,13 @@ public class WriteLoops {
135 177
         // you need to use a .equals for two Strings.
136 178
 
137 179
             // calling
138
-            w = w + 1;
180
+            //w = w + 1;
139 181
             // each time through the inner loop
140
-        
182
+        while(!gpsCurrentLocation().equals("Home")) {
183
+            driveSomeMore();
184
+            w += 1;
185
+        }
186
+        System.out.println("Honey, I'm Home!");
141 187
 
142 188
             return w;
143 189
     }
@@ -157,9 +203,15 @@ public class WriteLoops {
157 203
         // do your while loop here
158 204
  
159 205
             // calling
160
-            w = w + 1;
206
+            //w = w + 1;
161 207
             // each time through the inner loop
162 208
         
209
+        while(runningScore < highestScore) {
210
+            runningScore += currentScore;
211
+            currentScore = gameNextScore();
212
+            w += 1;
213
+        }
214
+            
163 215
         return w; // >= 3;
164 216
     }
165 217
 
@@ -174,9 +226,16 @@ public class WriteLoops {
174 226
         // do your while loop here
175 227
 
176 228
             // calling
177
-            w = w + 1;
229
+            // w = w + 1;
178 230
             // each time through the inner loop
179
-
231
+            
232
+                
233
+        do {
234
+            runningScore += currentScore;
235
+            currentScore = gameNextScore();
236
+            w += 1;  
237
+        } while(runningScore < highestScore);
238
+        System.out.print("Number of times through the loop is " + w);
180 239
         return w >= 3;
181 240
     }
182 241
 
@@ -190,9 +249,16 @@ public class WriteLoops {
190 249
         
191 250
 
192 251
         // calling
193
-        w = w + 1;
252
+        // w = w + 1;
194 253
         // each time through the inner loop
254
+        while(serverIsRunning()) {
255
+            waitFor(5);
256
+            w += 1;
257
+        }
195 258
         
259
+        if(!serverIsRunning()) {            
260
+            tryServerRestart("Help!", adminPhoneNumber);
261
+        }
196 262
         return w;
197 263
     }
198 264
 
@@ -201,6 +267,7 @@ public class WriteLoops {
201 267
     // and if it is, add 7 to “i”
202 268
     public int loop50by7() {
203 269
         int w = 0;
270
+        int i = 7;
204 271
 
205 272
 
206 273
             // calling

+ 1
- 1
WriteLoopsTest.java ファイルの表示

@@ -71,7 +71,7 @@ public class WriteLoopsTest
71 71
     public void Test2to32()
72 72
     {
73 73
         WriteLoops writeLoo1 = new WriteLoops();
74
-        assertEquals(0, writeLoo1.byTwoTo32());
74
+        assertEquals(16, writeLoo1.byTwoTo32());
75 75
     }
76 76
 
77 77
     @Test

+ 13
- 13
package.bluej ファイルの表示

@@ -1,22 +1,22 @@
1 1
 #BlueJ package file
2
-dependency1.from=WriteLoopsTest
3
-dependency1.to=WriteLoops
2
+dependency1.from=WriteIFsTest
3
+dependency1.to=WriteIFs
4 4
 dependency1.type=UsesDependency
5
-dependency2.from=WriteIFsTest
6
-dependency2.to=WriteIFs
5
+dependency2.from=WriteLoopsTest
6
+dependency2.to=WriteLoops
7 7
 dependency2.type=UsesDependency
8
-editor.fx.0.height=722
9
-editor.fx.0.width=800
10
-editor.fx.0.x=560
11
-editor.fx.0.y=118
12
-objectbench.height=101
13
-objectbench.width=740
8
+editor.fx.0.height=835
9
+editor.fx.0.width=1044
10
+editor.fx.0.x=396
11
+editor.fx.0.y=23
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