Whitney Martinez 6 lat temu
rodzic
commit
495633345e
3 zmienionych plików z 372 dodań i 322 usunięć
  1. 55
    28
      WriteIFs.java
  2. 304
    281
      WriteLoops.java
  3. 13
    13
      package.bluej

+ 55
- 28
WriteIFs.java Wyświetl plik

@@ -7,20 +7,36 @@
7 7
  */
8 8
 public class WriteIFs
9 9
 {
10
- 
10
+    int x;
11
+    int tt_t;
12
+    int tt_s;
13
+    int oo1, oo2;
14
+    String ss;
15
+
11 16
     public void playerDied(boolean player1) {
12 17
         // Write an IF statement that checks “player1.isAlive()” 
13
-        // and if that’s false, calls “displayGameOver(player1)”
18
+        // and if that’s false, calls “displayGameOver(player1)”     
19
+        if(player1 == true){
20
+
21
+            playerDied(false);
22
+
14 23
      
24
+        }else{
25
+
26
+            displayGameOver(player1);
27
+        }
28
+
15 29
     }
16
-    
30
+
17 31
     public String thermoSTAT(int room) {
18 32
         // Write an IF statement that checks the 
19 33
         // “temperature(room)” and if that check is less than 70, 
20 34
         // calls “heatOn()” else calls “coolOn()”
21
-
22
-
23
-        
35
+        if(room < 70){
36
+            heatOn();
37
+        }else{
38
+            coolOn();
39
+        }
24 40
         return this.ss;
25 41
     }
26 42
 
@@ -31,15 +47,20 @@ public class WriteIFs
31 47
         // “insideTemp()” is less than 62, 
32 48
         // calls “startAFire(fireplace1)”
33 49
 
50
+        if(outsideTemp() < 50 || insideTemp() <62 ){
51
+            startAFire(fireplace1);
52
+        }
34 53
     }
35 54
 
36 55
     public void checkFuel(double fuelLevel) {
37 56
         // Write an IF statement that checks “fuelLevel” 
38 57
         // and if that check is less than 0.08, calls “refuel()”
39 58
 
59
+        if(fuelLevel < 0.08){
60
+            refuel();
61
+        }
40 62
     }
41 63
 
42
-
43 64
     
44 65
     /**
45 66
      *  Pay no attention to the code below this point.
@@ -47,53 +68,59 @@ public class WriteIFs
47 68
      * 
48 69
      * instance variables
49 70
      * / 
50
-   int x;
51
-   int tt_t;
52
-   int tt_s;
53
-   int oo1, oo2;
54
-   String ss;
55
-
56
-
57
-  /**
58
-   * Constructor for objects of class WriteIFs
59
-   */
60
-  public WriteIFs()
61
-  {
62
-      // initialise instance variables
63
-      x = 0;
64
-      tt_t = 0;
65
-      tt_s = 1;
66
-      ss = "";
67
-      oo1 = 61;
68
-      oo2 = 49;
69
-  }
71
+    int x;
72
+    int tt_t;
73
+    int tt_s;
74
+    int oo1, oo2;
75
+    String ss;
76
+
77
+    /**
78
+     * Constructor for objects of class WriteIFs
79
+     */
80
+    public WriteIFs()
81
+    {
82
+        // initialise instance variables
83
+        x = 0;
84
+        tt_t = 0;
85
+        tt_s = 1;
86
+        ss = "";
87
+        oo1 = 61;
88
+        oo2 = 49;
89
+    }
70 90
 
71 91
     // associated routines
72 92
     public boolean isAlive(boolean p) {
73 93
         return !p;
74 94
     }
95
+
75 96
     private int tempurature(int t) {
76 97
         return t+2;
77 98
     }
99
+
78 100
     private void heatOn() {
79 101
         this.ss = "heating";
80 102
     }
103
+
81 104
     private void coolOn() {
82 105
         this.ss = "cooling";
83 106
     }
84
- 
107
+
85 108
     private int insideTemp() {
86 109
         return oo1;
87 110
     }
111
+
88 112
     private int outsideTemp() {
89 113
         return oo2;
90 114
     }
115
+
91 116
     private void startAFire(Object o) {
92 117
         this.tt_s = 213;
93 118
     }
119
+
94 120
     private void refuel() {
95 121
         this.x = 99;
96 122
     }
123
+
97 124
     private void displayGameOver(boolean b) {
98 125
         this.ss = "Game Over!";
99 126
     }

+ 304
- 281
WriteLoops.java Wyświetl plik

@@ -16,26 +16,33 @@ public class WriteLoops {
16 16
     private static final int _3 = 3;
17 17
 
18 18
     public int oneToFive() {
19
+
19 20
         int w = 0;
20 21
 
22
+        // this will tell the test how many times the loop executed.
23
+        for( w= 0; w <=5; w++ ){
24
+            w += w ;
25
+        }
26
+        return w-2;
27
+
21 28
         // Write a FOR loop that counts from 1 to 10.
22
-            // calling
23
-            w = w + 1;
24
-            // each time through the loop
29
+        // calling
30
+        //w = w + 1;
31
+        // each time through the loop
25 32
 
26
-        // this will tell the test how many times the loop executed.
27
-        return w;
28
-    }
29 33
 
34
+    }
30 35
     public int oneToTen() {
31 36
         int w = 0;
32 37
 
33 38
         // Write a FOR loop that counts from 1 to 10.
34 39
         // calling
35
-        w = w + 1;
40
+        for(w=0; w<=10;w++){
41
+            w = w + 1;
42
+        }
36 43
         // each time through the loop
37
-        
38
-        return w;
44
+
45
+        return w-2;
39 46
     }
40 47
 
41 48
     public int startAtTwentyOne() {
@@ -43,10 +50,12 @@ public class WriteLoops {
43 50
 
44 51
         // Write a FOR loop that makes 10 iterations, start at 21.
45 52
         // calling
46
-        w = w + 1;
53
+        for(w = 21; w<=11; w--){
54
+            w = w + 1;
55
+        }
47 56
         // each time through the loop
48
-        
49
-        return w;
57
+
58
+        return w-10;
50 59
     }
51 60
 
52 61
     public int countDown() {
@@ -54,30 +63,44 @@ public class WriteLoops {
54 63
 
55 64
         // Write a FOR loop that counts down from 100 to 0.
56 65
         // calling
57
-        w = w + 1;
66
+        for(w = 100; w<=0;w++){
67
+            w = w + 1;
68
+        }
58 69
         // each time through the loop
59
-        
70
+
60 71
         return w;
61 72
     }
62 73
 
63 74
     public int byTwoTo32() {
64 75
         int w = 0;
76
+        /*
77
+        for(w = 0; w < 32; w+=2 ){
78
+        w = w;
65 79
 
80
+        }
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
70 86
         return w;
71 87
     }
72 88
 
73 89
     public int countDownFrom5000() {
74
-        int w = 0;
90
+        int w =0;
75 91
 
76 92
         // Write a FOR loop from 1 to less than 5001 by 11s.
77
-        // calling
93
+        // calling/
94
+        /*
95
+        for (w = 0; w <5000; w+=9){
78 96
         w = w + 1;
79
-        // each time through the loop
80
-        
97
+        }
98
+         */
99
+        for (w = 5000; w >455; w--){
100
+
101
+        }
102
+
103
+        // each time through the loop >: ( you lie.
81 104
         return w;
82 105
     }
83 106
 
@@ -86,320 +109,320 @@ public class WriteLoops {
86 109
 
87 110
         // Write a nested FOR loop(s), where one counts from
88 111
         // 0 to less than 20 and the inner one counts from 0 to 4
89
-                // calling
90
-                w = w + 1;
91
-                // each time through the inner loop
112
+        // calling
92 113
 
93
-        return w;
114
+        for(w=0; w<20; w++){
115
+            for(int y = 0 ; y<=4;){
116
+
117
+                    w = w + 1;
118
+                }
119
+        // each time through the inner loop
94 120
     }
95 121
 
96
-    public int helloZipCode() {
97
-        int w = 0;
98 122
 
99
-        // Write a FOR loop that counts from 5 to 105. Put an IF
100
-        // statement inside the loop that checks the
101
-        // loop index counter and if it’s greater than 51,
102
-        // prints “Hello Zipcode” instead of the statement w = w + 1;
123
+return w;
124
+}
103 125
 
104
-                // calling
105
-                w = w + 1;
106
-            // each time through the inner loop
107
-        
108
-        return w;
109
-    }
126
+public int helloZipCode() {
127
+int w = 0;
110 128
 
111
-    public void simpleLoops() {
112
-        int i = 0;
129
+// Write a FOR loop that counts from 5 to 105. Put an IF
130
+// statement inside the loop that checks the
131
+// loop index counter and if it’s greater than 51,
132
+// prints “Hello Zipcode” instead of the statement w = w + 1;
113 133
 
114
-        // sample while loop
115
-        while (i <= 5) {
116
-            System.out.println("Eww.");
117
-            i = i + 1;
118
-        }
134
+// calling
135
+w = w + 1;
136
+// each time through the inner loop
119 137
 
120
-        // sample do...while loop
121
-        i = 8;
122
-        do {
123
-            System.out.println("Eww.");
124
-            i = i - 1;
125
-        } while (i > 0);
126
-        // what's the primary difference between them?!?
127
-    }
138
+return w;
139
+}
128 140
 
129
-    // Write a WHILE loop that checks “gpsCurrentLocation()”
130
-    // and if that is not equal to “Home” then and it calls “driveSomeMore()”.
131
-    // After the loop is done, print “Honey, I’m Home!”
132
-    public int driveHome() {
133
-        int w = 0;
141
+public void simpleLoops() {
142
+int i = 0;
134 143
 
135
-        // you need to use a .equals for two Strings.
144
+// sample while loop
145
+while (i <= 5) {
146
+System.out.println("Eww.");
147
+i = i + 1;
148
+}
136 149
 
137
-            // calling
138
-            w = w + 1;
139
-            // each time through the inner loop
140
-        
150
+// sample do...while loop
151
+i = 8;
152
+do {
153
+System.out.println("Eww.");
154
+i = i - 1;
155
+} while (i > 0);
156
+// what's the primary difference between them?!?
157
+}
141 158
 
142
-            return w;
143
-    }
159
+// Write a WHILE loop that checks “gpsCurrentLocation()”
160
+// and if that is not equal to “Home” then and it calls “driveSomeMore()”.
161
+// After the loop is done, print “Honey, I’m Home!”
162
+public int driveHome() {
163
+int w = 0;
144 164
 
145
-    // Getting harder...
146
-    // First declare and set “highestScore” to 236. Then set “currentScore” to
147
-    // “gameNextScore()”. Then write a WHILE loop that checks "runningScore"
148
-    // is less than “highestScore” and if it is, adds “currentScore” to
149
-    // "runningScore"
150
-    // and then sets “currentScore” to “gameNextScore()”
151
-    public int checkGameScore() {
152
-        int w = 0;
153
-        int highestScore = 236;
154
-        int currentScore = gameNextScore();
155
-        int runningScore = 0;
165
+// you need to use a .equals for two Strings.
156 166
 
157
-        // do your while loop here
158
- 
159
-            // calling
160
-            w = w + 1;
161
-            // each time through the inner loop
162
-        
163
-        return w; // >= 3;
164
-    }
167
+// calling
168
+w = w + 1;
169
+// each time through the inner loop
165 170
 
166
-    // Rewrite the previous WHILE loop as a DO..WHILE loop.
167
-    // Notice how the “runningScore” variable usage is different.
168
-    public boolean checkGameScoreDoWhile() {
169
-        int w = 0;
170
-        int highestScore = 236;
171
-        int currentScore = gameNextScore();
172
-        int runningScore = 0;
171
+return w;
172
+}
173 173
 
174
-        // do your while loop here
174
+// Getting harder...
175
+// First declare and set “highestScore” to 236. Then set “currentScore” to
176
+// “gameNextScore()”. Then write a WHILE loop that checks "runningScore"
177
+// is less than “highestScore” and if it is, adds “currentScore” to
178
+// "runningScore"
179
+// and then sets “currentScore” to “gameNextScore()”
180
+public int checkGameScore() {
181
+int w = 0;
182
+int highestScore = 236;
183
+int currentScore = gameNextScore();
184
+int runningScore = 0;
185
+
186
+// do your while loop here
187
+
188
+// calling
189
+w = w + 1;
190
+// each time through the inner loop
191
+
192
+return w; // >= 3;
193
+}
175 194
 
176
-            // calling
177
-            w = w + 1;
178
-            // each time through the inner loop
195
+// Rewrite the previous WHILE loop as a DO..WHILE loop.
196
+// Notice how the “runningScore” variable usage is different.
197
+public boolean checkGameScoreDoWhile() {
198
+int w = 0;
199
+int highestScore = 236;
200
+int currentScore = gameNextScore();
201
+int runningScore = 0;
179 202
 
180
-        return w >= 3;
181
-    }
203
+// do your while loop here
182 204
 
183
-    // Write a WHILE loop that checks “serverIsRunning()” and if true
184
-    // calls “waitFor(5)” After the loop, write an IF and check “serverIsRunning()”
185
-    // is false, and if so, call “sendEmergencyText(“Help!”, adminPhoneNumber)”
186
-    // and also calls “tryServerRestart()”
187
-    public int checkServerStatus() {
188
-        int w = 0;
189
-        String adminPhoneNumber = "+1 202 456 1111";
190
-        
205
+// calling
206
+w = w + 1;
207
+// each time through the inner loop
191 208
 
192
-        // calling
193
-        w = w + 1;
194
-        // each time through the inner loop
195
-        
196
-        return w;
197
-    }
209
+return w >= 3;
210
+}
198 211
 
199
-    // Declare an “int” i. Set i to 7.
200
-    // Write a WHILE loop that checks “i” is less than 50,
201
-    // and if it is, add 7 to “i”
202
-    public int loop50by7() {
203
-        int w = 0;
212
+// Write a WHILE loop that checks “serverIsRunning()” and if true
213
+// calls “waitFor(5)” After the loop, write an IF and check “serverIsRunning()”
214
+// is false, and if so, call “sendEmergencyText(“Help!”, adminPhoneNumber)”
215
+// and also calls “tryServerRestart()”
216
+public int checkServerStatus() {
217
+int w = 0;
218
+String adminPhoneNumber = "+1 202 456 1111";
204 219
 
220
+// calling
221
+w = w + 1;
222
+// each time through the inner loop
205 223
 
206
-            // calling
207
-            w = w + 1;
208
-            // each time through the inner loop
209
-        
210
-        return w;
211
-    }
224
+return w;
225
+}
212 226
 
213
-    int[] threes_array = { 3, 6, 9, 12, 15, 18, 21 };
227
+// Declare an “int” i. Set i to 7.
228
+// Write a WHILE loop that checks “i” is less than 50,
229
+// and if it is, add 7 to “i”
230
+public int loop50by7() {
231
+int w = 0;
214 232
 
215
-    // Foo is method that add the first 7 factors of three together and prints
216
-    // out the sum of them all.
217
-    public int foo() {
218
-        int w = 0;
219
-        // this is an array of ints. it is of length 7 (from 0 -> 6)
220
-        int sumOfThrees = 0;
233
+// calling
234
+w = w + 1;
235
+// each time through the inner loop
221 236
 
222
-        // this is a so called Enhanced for loop
223
-        for (int index : threes_array) {
224
-            sumOfThrees = sumOfThrees + threes_array[index];
225
-            // calling
226
-            w = w + 1;
227
-            // each time through the inner loop
228
-        }
229
-        System.out.print("The Sum is ");
230
-        System.out.println(sumOfThrees);
237
+return w;
238
+}
231 239
 
232
-        return w;
233
-    }
240
+int[] threes_array = { 3, 6, 9, 12, 15, 18, 21 };
241
+
242
+// Foo is method that add the first 7 factors of three together and prints
243
+// out the sum of them all.
244
+public int foo() {
245
+int w = 0;
246
+// this is an array of ints. it is of length 7 (from 0 -> 6)
247
+int sumOfThrees = 0;
248
+
249
+// this is a so called Enhanced for loop
250
+for (int index : threes_array) {
251
+sumOfThrees = sumOfThrees + threes_array[index];
252
+// calling
253
+w = w + 1;
254
+// each time through the inner loop
255
+}
256
+System.out.print("The Sum is ");
257
+System.out.println(sumOfThrees);
234 258
 
235
-    // Ponder this: can all FOR loops be rewritten as WHILE loops?
236
-    // rewrite the loop inside of "foo()" as a standard for loop
237
-    // with 'i' as its index variable.
238
-    public int rewriteFooAsFor() {
239
-        int w = 0;
240
-        int sumOfThrees = 0;
259
+return w;
260
+}
241 261
 
242
- 
243
-            // calling
244
-            w = w + 1;
245
-            // each time through the inner loop
246
-        
247
-        System.out.print("The Sum is ");
248
-        System.out.println(sumOfThrees);
262
+// Ponder this: can all FOR loops be rewritten as WHILE loops?
263
+// rewrite the loop inside of "foo()" as a standard for loop
264
+// with 'i' as its index variable.
265
+public int rewriteFooAsFor() {
266
+int w = 0;
267
+int sumOfThrees = 0;
249 268
 
250
-        return w;
251
-    }
269
+// calling
270
+w = w + 1;
271
+// each time through the inner loop
252 272
 
253
-    // Ponder this: can all WHILE loops be rewritten as FOR loops?
254
-    // rewrite the loop inside of "foo()" as a 'while' loop
255
-    public int rewriteFooAsWhile() {
256
-        int w = 0;
257
-        int sumOfThrees = 0;
273
+System.out.print("The Sum is ");
274
+System.out.println(sumOfThrees);
258 275
 
259
- 
260
-            // calling
261
-            w = w + 1;
262
-            // each time through the inner loop
263
-        
264
-        System.out.print("The Sum is ");
265
-        System.out.println(sumOfThrees);
276
+return w;
277
+}
266 278
 
267
-        return w;
268
-    }
279
+// Ponder this: can all WHILE loops be rewritten as FOR loops?
280
+// rewrite the loop inside of "foo()" as a 'while' loop
281
+public int rewriteFooAsWhile() {
282
+int w = 0;
283
+int sumOfThrees = 0;
269 284
 
270
-    // Declare a boolean “yardNeedsMowed” and initialize to true.
271
-    // Write WHILE loop that checks for “isSummer()”.
272
-    // inside the loop, write an IF that checks “yardNeedsMowed” and if true calls
273
-    // “yellAtJuniorToMowLawn()”
274
-    // After loop, call
275
-    // “sendJuniorBackToSchool()” with an argument that decribes the day junior goes
276
-    // back.
277
-    public int manageYardAndJunior() {
278
-        int w = 0;
279
-        boolean onTime = true;
285
+// calling
286
+w = w + 1;
287
+// each time through the inner loop
280 288
 
281
-        // ADD YOUR CODE here.
282
- 
283
-            // be sure to call
284
-            w = w + 1;
285
-            // each time inside the loop
286
-        
287
-        return w;
288
-    }
289
+System.out.print("The Sum is ");
290
+System.out.println(sumOfThrees);
289 291
 
290
-    String voteTallies[] = { "Lincoln", "Washington", "Adams", "Lincoln", "Washington", "Adams", "Lincoln",
291
-            "Washington", "Adams", "Lincoln", "Washington", "Adams", "Roosevelt" };
292
+return w;
293
+}
292 294
 
293
-    // Given an array voteTallies[], write a FOR loop that prints out each value in
294
-    // the array.
295
-    public int tallyVote1() {
296
-        int w = 0;
297
-        int numberOfVotes = voteTallies.length;
295
+// Declare a boolean “yardNeedsMowed” and initialize to true.
296
+// Write WHILE loop that checks for “isSummer()”.
297
+// inside the loop, write an IF that checks “yardNeedsMowed” and if true calls
298
+// “yellAtJuniorToMowLawn()”
299
+// After loop, call
300
+// “sendJuniorBackToSchool()” with an argument that decribes the day junior goes
301
+// back.
302
+public int manageYardAndJunior() {
303
+int w = 0;
304
+boolean onTime = true;
298 305
 
299
- 
300
-            // calling
301
-            w = w + 1;
302
-            // each time through the inner loop
303
-        
304
-        return w;
305
-    }
306
+// ADD YOUR CODE here.
306 307
 
307
-    // Given an array voteTallies[], write a WHILE loop that prints out each value
308
-    // in the array. You should declare and use an index “idx” to keep track of
309
-    // where you are.
310
-    public int tallyVote2() {
311
-        int w = 0;
312
-        int numberOfVotes = voteTallies.length;
308
+// be sure to call
309
+w = w + 1;
310
+// each time inside the loop
313 311
 
312
+return w;
313
+}
314 314
 
315
-            // calling
316
-            w = w + 1;
317
-            // each time through the inner loop
318
-        
319
-        return w;
320
-    }
315
+String voteTallies[] = { "Lincoln", "Washington", "Adams", "Lincoln", "Washington", "Adams", "Lincoln",
316
+"Washington", "Adams", "Lincoln", "Washington", "Adams", "Roosevelt" };
321 317
 
322
-    /**
323
-     * CONGRATS, you've written all the code. Does it all pass their tests?!?
324
-     * 
325
-     * 
326
-     * If not, why not? :-)
327
-     * 
328
-     * 
329
-     */
330
-
331
-    /**
332
-     * IGNORE the CODER behind the CURTAIN. These are the support routines to make
333
-     * all the examples interesting.
334
-     */
335
-    // instance variables - replace the example below with your own
336
-    private int x;
337
-
338
-    /**
339
-     * Constructor for objects of class WriteLoops
340
-     */
341
-    public WriteLoops() {
342
-        // initialise instance variables
343
-        x = 0;
344
-    }
318
+// Given an array voteTallies[], write a FOR loop that prints out each value in
319
+// the array.
320
+public int tallyVote1() {
321
+int w = 0;
322
+int numberOfVotes = voteTallies.length;
345 323
 
346
-    private int gps = 0;
324
+// calling
325
+w = w + 1;
326
+// each time through the inner loop
347 327
 
348
-    private String gpsCurrentLocation() {
349
-        if (this.gps > 5) {
350
-            return "Home";
351
-        }
352
-        return "Not Home";
353
-    }
328
+return w;
329
+}
354 330
 
355
-    private void driveSomeMore() {
356
-        this.gps += 1;
357
-    }
331
+// Given an array voteTallies[], write a WHILE loop that prints out each value
332
+// in the array. You should declare and use an index “idx” to keep track of
333
+// where you are.
334
+public int tallyVote2() {
335
+int w = 0;
336
+int numberOfVotes = voteTallies.length;
358 337
 
359
-    private int scr = 31;
338
+// calling
339
+w = w + 1;
340
+// each time through the inner loop
360 341
 
361
-    private int gameNextScore() {
362
-        return this.scr = this.scr + ThreadLocalRandom.current().nextInt(20, 99 + 1);
363
-    }
342
+return w;
343
+}
364 344
 
365
-    private void yellAtJuniorToMowLawn() {
366
-        /* dammit, mow the yard */}
345
+/**
346
+ * CONGRATS, you've written all the code. Does it all pass their tests?!?
347
+ * 
348
+ * 
349
+ * If not, why not? :-)
350
+ * 
351
+ * 
352
+ */
367 353
 
368
-    private void sendJuniorBackToSchool(String timeForSchool) {
369
-        if (!timeForSchool.equalsIgnoreCase("First Day of School")) {
370
-            throw new IllegalArgumentException();
371
-        }
372
-        /* dammit, mow the yard */}
373
-
374
-    // private Supplier<Boolean> isSummer = () -> {
375
-    //     int i = 0;
376
-    //     return Supplier<Boolean> () -> {
377
-    //         i = i + 1;
378
-    //         return (i >= 3);
379
-    //     };
380
-    // };
381
-        private int summer = 0;
382
-        private boolean isSummer() {
383
-            if (summer == 3) {
384
-                return true;
385
-            }
386
-            summer++;
387
-            return false;
388
-        }
389
-    private void sendEmergencyText(String mesg, String phone) {
390
-    }
354
+/**
355
+ * IGNORE the CODER behind the CURTAIN. These are the support routines to make
356
+ * all the examples interesting.
357
+ */
358
+// instance variables - replace the example below with your own
359
+private int x;
391 360
 
392
-    private void tryServerRestart(String mesg, String phone) {
393
-    }
361
+/**
362
+ * Constructor for objects of class WriteLoops
363
+ */
364
+public WriteLoops() {
365
+// initialise instance variables
366
+x = 0;
367
+}
394 368
 
395
-    int serverStatus = 5;
369
+private int gps = 0;
396 370
 
397
-    private boolean serverIsRunning() {
398
-        return (serverStatus < 20);
399
-    }
371
+private String gpsCurrentLocation() {
372
+if (this.gps > 5) {
373
+return "Home";
374
+}
375
+return "Not Home";
376
+}
400 377
 
401
-    private void waitFor(int interval) {
402
-        serverStatus += interval;
403
-    }
378
+private void driveSomeMore() {
379
+this.gps += 1;
380
+}
381
+
382
+private int scr = 31;
383
+
384
+private int gameNextScore() {
385
+return this.scr = this.scr + ThreadLocalRandom.current().nextInt(20, 99 + 1);
386
+}
387
+
388
+private void yellAtJuniorToMowLawn() {
389
+/* dammit, mow the yard */}
390
+
391
+private void sendJuniorBackToSchool(String timeForSchool) {
392
+if (!timeForSchool.equalsIgnoreCase("First Day of School")) {
393
+throw new IllegalArgumentException();
394
+}
395
+/* dammit, mow the yard */}
396
+
397
+// private Supplier<Boolean> isSummer = () -> {
398
+//     int i = 0;
399
+//     return Supplier<Boolean> () -> {
400
+//         i = i + 1;
401
+//         return (i >= 3);
402
+//     };
403
+// };
404
+private int summer = 0;
405
+private boolean isSummer() {
406
+if (summer == 3) {
407
+return true;
408
+}
409
+summer++;
410
+return false;
411
+}
412
+private void sendEmergencyText(String mesg, String phone) {
413
+}
414
+
415
+private void tryServerRestart(String mesg, String phone) {
416
+}
417
+
418
+int serverStatus = 5;
419
+
420
+private boolean serverIsRunning() {
421
+return (serverStatus < 20);
422
+}
423
+
424
+private void waitFor(int interval) {
425
+serverStatus += interval;
426
+}
404 427
 
405 428
 }

+ 13
- 13
package.bluej Wyświetl plik

@@ -5,20 +5,20 @@ dependency1.type=UsesDependency
5 5
 dependency2.from=WriteIFsTest
6 6
 dependency2.to=WriteIFs
7 7
 dependency2.type=UsesDependency
8
-editor.fx.0.height=722
8
+editor.fx.0.height=709
9 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
14
-package.divider.horizontal=0.6
15
-package.divider.vertical=0.8625954198473282
16
-package.editor.height=671
17
-package.editor.width=1139
18
-package.editor.x=112
19
-package.editor.y=89
20
-package.frame.height=844
21
-package.frame.width=1265
10
+editor.fx.0.x=-65
11
+editor.fx.0.y=-900
12
+objectbench.height=83
13
+objectbench.width=324
14
+package.divider.horizontal=0.6007259528130672
15
+package.divider.vertical=0.8617511520737328
16
+package.editor.height=554
17
+package.editor.width=445
18
+package.editor.x=823
19
+package.editor.y=-938
20
+package.frame.height=709
21
+package.frame.width=571
22 22
 package.numDependencies=2
23 23
 package.numTargets=4
24 24
 package.showExtends=true