Brandon Defrancis 8 лет назад
Родитель
Сommit
fec803cf41
3 измененных файлов: 54 добавлений и 22 удалений
  1. 25
    5
      WriteIFs.java
  2. 18
    6
      WriteLoops.java
  3. 11
    11
      package.bluej

+ 25
- 5
WriteIFs.java Просмотреть файл

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

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

@@ -18,9 +18,11 @@ 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 1 to 5.
22 22
             // calling
23
+            for (int i = 1; i <=5; i++){
23 24
             w = w + 1;
25
+        }
24 26
             // each time through the loop
25 27
 
26 28
         // this will tell the test how many times the loop executed.
@@ -32,7 +34,9 @@ public class WriteLoops {
32 34
 
33 35
         // Write a FOR loop that counts from 1 to 10.
34 36
         // calling
35
-        w = w + 1;
37
+            for (int i = 1; i <=10; i++){
38
+            w = w + 1;
39
+        }
36 40
         // each time through the loop
37 41
         
38 42
         return w;
@@ -43,7 +47,9 @@ public class WriteLoops {
43 47
 
44 48
         // Write a FOR loop that makes 10 iterations, start at 21.
45 49
         // calling
46
-        w = w + 1;
50
+            for (int i = 21; i <=31; i++){
51
+            w = w + 1;
52
+        }
47 53
         // each time through the loop
48 54
         
49 55
         return w;
@@ -54,7 +60,9 @@ public class WriteLoops {
54 60
 
55 61
         // Write a FOR loop that counts down from 100 to 0.
56 62
         // calling
57
-        w = w + 1;
63
+            for (int i = 100; i > 0; i--){
64
+            w = w + 1;
65
+        }
58 66
         // each time through the loop
59 67
         
60 68
         return w;
@@ -65,7 +73,9 @@ public class WriteLoops {
65 73
 
66 74
         // Write a FOR loop from 0 to 32 by 2s.
67 75
         // calling
68
-        w = w + 1;
76
+            for (int i = 32; i <=0; i+=2){
77
+            w = w + 1;
78
+        }
69 79
         // each time through the loop
70 80
         return w;
71 81
     }
@@ -75,7 +85,9 @@ public class WriteLoops {
75 85
 
76 86
         // Write a FOR loop from 1 to less than 5001 by 11s.
77 87
         // calling
78
-        w = w + 1;
88
+            for (int i = 5001; i > 0; i-=11){
89
+            w = w + 1;
90
+        }
79 91
         // each time through the loop
80 92
         
81 93
         return w;

+ 11
- 11
package.bluej Просмотреть файл

@@ -7,18 +7,18 @@ dependency2.to=WriteIFs
7 7
 dependency2.type=UsesDependency
8 8
 editor.fx.0.height=722
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
10
+editor.fx.0.x=692
11
+editor.fx.0.y=-936
12
+objectbench.height=109
13
+objectbench.width=605
14 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
15
+package.divider.vertical=0.8491547464239272
16
+package.editor.height=646
17
+package.editor.width=503
18
+package.editor.x=-16
19
+package.editor.y=-946
20
+package.frame.height=827
21
+package.frame.width=629
22 22
 package.numDependencies=2
23 23
 package.numTargets=4
24 24
 package.showExtends=true