Sfoglia il codice sorgente

{in progress after questions}

Jacqueline Joson 6 anni fa
parent
commit
ca74eff778
2 ha cambiato i file con 35 aggiunte e 22 eliminazioni
  1. 24
    10
      WriteIFs.java
  2. 11
    12
      WriteLoops.java

+ 24
- 10
WriteIFs.java Vedi File

@@ -1,31 +1,44 @@
1 1
 
2
+
2 3
 /**
3 4
  * Write a description of class WriteIFs here.
4 5
  *
5
- * @author (your name)
6
- * @version (a version number or a date)
6
+ * @JaeJoson
7
+ * @10/20/2018
7 8
  */
8 9
 public class WriteIFs
9 10
 {
11
+   int x; 
12
+   int tt_t;
13
+   int tt_s;
14
+   int oo1, oo2;
15
+   String ss;
10 16
  
11 17
     public void playerDied(boolean player1) {
12
-        // Write an IF statement that checks “player1.isAlive()” 
18
+        if (!isAlive(player1)); {
19
+            return displayGameOver;
20
+        }// Write an IF statement that checks “player1.isAlive()” 
13 21
         // and if that’s false, calls “displayGameOver(player1)”
14 22
      
15 23
     }
16
-    
24
+
17 25
     public String thermoSTAT(int room) {
18
-        // Write an IF statement that checks the 
26
+        if (tempurature(room) < 70) {
27
+            heatOn();
28
+        } else {
29
+            coolOn();
30
+        }// Write an IF statement that checks the 
19 31
         // “temperature(room)” and if that check is less than 70, 
20 32
         // calls “heatOn()” else calls “coolOn()”
21 33
 
22
-
23
-        
24 34
         return this.ss;
25 35
     }
26 36
 
27 37
     public void fireplaceControl(Object fireplace1) {
28
-        // Write an IF statement that checks 
38
+        if ((oo2 < 50) && (oo1 < 62)) {
39
+            startAFire(fireplace1); 
40
+        }
41
+            // Write an IF statement that checks 
29 42
         // “outsideTemp()” is less than 50 
30 43
         // AND 
31 44
         // “insideTemp()” is less than 62, 
@@ -34,11 +47,12 @@ public class WriteIFs
34 47
     }
35 48
 
36 49
     public void checkFuel(double fuelLevel) {
37
-        // Write an IF statement that checks “fuelLevel” 
50
+        if (x < 0.08) {
51
+            refuel();// Write an IF statement that checks “fuelLevel” 
38 52
         // and if that check is less than 0.08, calls “refuel()”
39 53
 
40 54
     }
41
-
55
+}
42 56
 
43 57
     
44 58
     /**

+ 11
- 12
WriteLoops.java Vedi File

@@ -18,10 +18,10 @@ public class WriteLoops {
18 18
     public int oneToFive() {
19 19
         int w = 0;
20 20
 
21
-        // Write a FOR loop that counts from 1 to 10.
21
+        for (w = 0; w < 5; w++); {// Write a FOR loop that counts from 1 to 10.
22 22
             // calling
23 23
             w = w + 1;
24
-            // each time through the loop
24
+        }// each time through the loop
25 25
 
26 26
         // this will tell the test how many times the loop executed.
27 27
         return w;
@@ -30,10 +30,9 @@ public class WriteLoops {
30 30
     public int oneToTen() {
31 31
         int w = 0;
32 32
 
33
-        // Write a FOR loop that counts from 1 to 10.
34
-        // calling
33
+        for (w = 0; w < 10; w++); {// Write a FOR loop that counts from 1 to 10.
35 34
         w = w + 1;
36
-        // each time through the loop
35
+        }// each time through the loop
37 36
         
38 37
         return w;
39 38
     }
@@ -41,21 +40,21 @@ public class WriteLoops {
41 40
     public int startAtTwentyOne() {
42 41
         int w = 0;
43 42
 
44
-        // Write a FOR loop that makes 10 iterations, start at 21.
43
+        for (w = 21; w < 31; w++) {// Write a FOR loop that makes 10 iterations, start at 21.
45 44
         // calling
46 45
         w = w + 1;
47
-        // each time through the loop
48
-        
46
+        }// each time through the loop
47
+        System.out.print(w);
49 48
         return w;
50 49
     }
51 50
 
52 51
     public int countDown() {
53 52
         int w = 0;
54 53
 
55
-        // Write a FOR loop that counts down from 100 to 0.
54
+        for (w = 100; w >= 0; w--;) {// Write a FOR loop that counts down from 100 to 0.
56 55
         // calling
57 56
         w = w + 1;
58
-        // each time through the loop
57
+        }// each time through the loop
59 58
         
60 59
         return w;
61 60
     }
@@ -63,10 +62,10 @@ public class WriteLoops {
63 62
     public int byTwoTo32() {
64 63
         int w = 0;
65 64
 
66
-        // Write a FOR loop from 0 to 32 by 2s.
65
+        for (w = 0; w < 32; w += 2) {// Write a FOR loop from 0 to 32 by 2s.
67 66
         // calling
68 67
         w = w + 1;
69
-        // each time through the loop
68
+        }// each time through the loop
70 69
         return w;
71 70
     }
72 71