ソースを参照

checkpointing my work

Jose Bedolla 6 年 前
コミット
8a9c85942e
共有3 個のファイルを変更した60 個の追加23 個の削除を含む
  1. 32
    17
      WriteIFs.java
  2. 6
    0
      WriteIFsTest.java
  3. 22
    6
      WriteLoops.java

+ 32
- 17
WriteIFs.java ファイルの表示

@@ -5,12 +5,26 @@
5 5
  * @author (your name)
6 6
  * @version (a version number or a date)
7 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 18
         // Write an IF statement that checks “player1.isAlive()” 
13 19
         // and if that’s false, calls “displayGameOver(player1)”
20
+        if(isAlive(true))
21
+        {
22
+           System.out.println(player1);
23
+        } 
24
+            else 
25
+                {
26
+                    displayGameOver(player1);
27
+                }
14 28
      
15 29
     }
16 30
     
@@ -18,9 +32,14 @@ public class WriteIFs
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()”
35
+        if(temperature(room)<70)
36
+        {
37
+            heatOn();
38
+        }
39
+        else {
40
+            coolOn();
41
+        }
21 42
 
22
-
23
-        
24 43
         return this.ss;
25 44
     }
26 45
 
@@ -30,30 +49,25 @@ public class WriteIFs
30 49
         // AND 
31 50
         // “insideTemp()” is less than 62, 
32 51
         // calls “startAFire(fireplace1)”
52
+        if((outsideTemp() < 50) || (insideTemp()<62))
53
+        {
54
+            startAFire(fireplace1);
55
+        }
56
+        
33 57
 
34 58
     }
35 59
 
36 60
     public void checkFuel(double fuelLevel) {
37 61
         // Write an IF statement that checks “fuelLevel” 
38 62
         // and if that check is less than 0.08, calls “refuel()”
63
+        if(fuelLevel < 0.08)
64
+        {
65
+            refuel();
66
+        }
39 67
 
40 68
     }
41 69
 
42 70
 
43
-    
44
-    /**
45
-     *  Pay no attention to the code below this point.
46
-     * 
47
-     * 
48
-     * instance variables
49
-     * / 
50
-   int x;
51
-   int tt_t;
52
-   int tt_s;
53
-   int oo1, oo2;
54
-   String ss;
55
-
56
-
57 71
   /**
58 72
    * Constructor for objects of class WriteIFs
59 73
    */
@@ -70,9 +84,10 @@ public class WriteIFs
70 84
 
71 85
     // associated routines
72 86
     public boolean isAlive(boolean p) {
87
+    
73 88
         return !p;
74 89
     }
75
-    private int tempurature(int t) {
90
+    private int temperature(int t) {
76 91
         return t+2;
77 92
     }
78 93
     private void heatOn() {

+ 6
- 0
WriteIFsTest.java ファイルの表示

@@ -13,6 +13,12 @@ import org.junit.Test;
13 13
  */
14 14
 public class WriteIFsTest
15 15
 {
16
+   int x;
17
+   int tt_t;
18
+   int tt_s;
19
+   int oo1, oo2;
20
+   String ss;
21
+   
16 22
     private static final double _0_5 = 0.5;
17 23
     private static final double _0_04 = 0.04;
18 24
 

+ 22
- 6
WriteLoops.java ファイルの表示

@@ -18,9 +18,13 @@ 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
+        // Write a FOR loop that counts from 5 to 10.
22 22
             // calling
23
-            w = w + 1;
23
+            for(int i =5; i < 10; i++)
24
+            {
25
+                w = w +1;
26
+            }
27
+            
24 28
             // each time through the loop
25 29
 
26 30
         // this will tell the test how many times the loop executed.
@@ -32,7 +36,10 @@ public class WriteLoops {
32 36
 
33 37
         // Write a FOR loop that counts from 1 to 10.
34 38
         // calling
35
-        w = w + 1;
39
+                   for(int i =0; i < 10; i++)
40
+            {
41
+                w = w +1;
42
+            }
36 43
         // each time through the loop
37 44
         
38 45
         return w;
@@ -43,7 +50,10 @@ 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(int i =21; i < 32; i++)
54
+            {
55
+                w = w +1;
56
+            }
47 57
         // each time through the loop
48 58
         
49 59
         return w;
@@ -54,7 +64,10 @@ public class WriteLoops {
54 64
 
55 65
         // Write a FOR loop that counts down from 100 to 0.
56 66
         // calling
57
-        w = w + 1;
67
+            for(int i =100; i > 0; i--)
68
+            {
69
+                w = w +1;
70
+            }
58 71
         // each time through the loop
59 72
         
60 73
         return w;
@@ -65,7 +78,10 @@ public class WriteLoops {
65 78
 
66 79
         // Write a FOR loop from 0 to 32 by 2s.
67 80
         // calling
68
-        w = w + 1;
81
+        for(int i = 1; i <= 32; i+=2)
82
+        {
83
+            w = w + 1;
84
+        }
69 85
         // each time through the loop
70 86
         return w;
71 87
     }