Просмотр исходного кода

all tests pass for WriteLoops object, still need to write several untested methods

Margaret Pierse 8 лет назад
Родитель
Сommit
9d80fa7f79
2 измененных файлов: 16 добавлений и 17 удалений
  1. 14
    7
      WriteLoops.java
  2. 2
    10
      WriteLoopsTest.java

+ 14
- 7
WriteLoops.java Просмотреть файл

178
             w = w + 1;
178
             w = w + 1;
179
             // each time through the inner loop
179
             // each time through the inner loop
180
         }
180
         }
181
+
181
         return w; // >= 3;
182
         return w; // >= 3;
182
     }
183
     }
183
 
184
 
190
         int runningScore = 0;
191
         int runningScore = 0;
191
 
192
 
192
         // do your while loop here
193
         // do your while loop here
193
-
194
-        // calling
195
-        w = w + 1;
194
+        do {
195
+            runningScore+= currentScore;
196
+            // calling
197
+            w = w + 1;
198
+        } while (runningScore<highestScore);
196
         // each time through the inner loop
199
         // each time through the inner loop
197
 
200
 
198
         return w >= 3;
201
         return w >= 3;
205
     public int checkServerStatus() {
208
     public int checkServerStatus() {
206
         int w = 0;
209
         int w = 0;
207
         String adminPhoneNumber = "+1 202 456 1111";
210
         String adminPhoneNumber = "+1 202 456 1111";
208
-
209
-        // calling
210
-        w = w + 1;
211
+        while (serverIsRunning()){
212
+            // calling
213
+            waitFor(5);
214
+            w = w + 1;}
211
         // each time through the inner loop
215
         // each time through the inner loop
212
-
216
+        if (!serverIsRunning()){
217
+            sendEmergencyText("Help!", adminPhoneNumber);
218
+            tryServerRestart("Help!", adminPhoneNumber);
219
+        }
213
         return w;
220
         return w;
214
     }
221
     }
215
 
222
 

+ 2
- 10
WriteLoopsTest.java Просмотреть файл

1
 
1
 
2
-
3
 import static org.junit.Assert.*;
2
 import static org.junit.Assert.*;
4
 import org.junit.After;
3
 import org.junit.After;
5
 import org.junit.Before;
4
 import org.junit.Before;
40
     {
39
     {
41
     }
40
     }
42
 
41
 
43
-
44
     @Test
42
     @Test
45
     public void TestOneToFive()
43
     public void TestOneToFive()
46
     {
44
     {
47
         WriteLoops writeLoo1 = new WriteLoops();
45
         WriteLoops writeLoo1 = new WriteLoops();
48
         assertEquals(5, writeLoo1.oneToFive());
46
         assertEquals(5, writeLoo1.oneToFive());
49
     }
47
     }
48
+
50
     @Test
49
     @Test
51
     public void TestOneToTen()
50
     public void TestOneToTen()
52
     {
51
     {
53
         WriteLoops writeLoo1 = new WriteLoops();
52
         WriteLoops writeLoo1 = new WriteLoops();
54
         assertEquals(10, writeLoo1.oneToTen());
53
         assertEquals(10, writeLoo1.oneToTen());
55
     }
54
     }
55
+
56
     @Test
56
     @Test
57
     public void TestStartAtTwentyOne()
57
     public void TestStartAtTwentyOne()
58
     {
58
     {
103
     }
103
     }
104
 
104
 
105
 
105
 
106
-
107
     @Test
106
     @Test
108
     public void TestCheckGameScore()
107
     public void TestCheckGameScore()
109
     {
108
     {
125
         assertEquals(3, writeLoo1.checkServerStatus());
124
         assertEquals(3, writeLoo1.checkServerStatus());
126
     }
125
     }
127
 
126
 
128
-    
129
 }
127
 }
130
 
128
 
131
 
129
 
133
 
131
 
134
 
132
 
135
 
133
 
136
-
137
-
138
-
139
-
140
-
141
-