Browse Source

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

Margaret Pierse 6 years ago
parent
commit
9d80fa7f79
2 changed files with 16 additions and 17 deletions
  1. 14
    7
      WriteLoops.java
  2. 2
    10
      WriteLoopsTest.java

+ 14
- 7
WriteLoops.java View File

@@ -178,6 +178,7 @@ public class WriteLoops {
178 178
             w = w + 1;
179 179
             // each time through the inner loop
180 180
         }
181
+
181 182
         return w; // >= 3;
182 183
     }
183 184
 
@@ -190,9 +191,11 @@ public class WriteLoops {
190 191
         int runningScore = 0;
191 192
 
192 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 199
         // each time through the inner loop
197 200
 
198 201
         return w >= 3;
@@ -205,11 +208,15 @@ public class WriteLoops {
205 208
     public int checkServerStatus() {
206 209
         int w = 0;
207 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 215
         // each time through the inner loop
212
-
216
+        if (!serverIsRunning()){
217
+            sendEmergencyText("Help!", adminPhoneNumber);
218
+            tryServerRestart("Help!", adminPhoneNumber);
219
+        }
213 220
         return w;
214 221
     }
215 222
 

+ 2
- 10
WriteLoopsTest.java View File

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