Brandon Defrancis před 8 roky
rodič
revize
fec803cf41
3 změnil soubory, kde provedl 54 přidání a 22 odebrání
  1. 25
    5
      WriteIFs.java
  2. 18
    6
      WriteLoops.java
  3. 11
    11
      package.bluej

+ 25
- 5
WriteIFs.java Zobrazit soubor

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

+ 18
- 6
WriteLoops.java Zobrazit soubor

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

+ 11
- 11
package.bluej Zobrazit soubor

7
 dependency2.type=UsesDependency
7
 dependency2.type=UsesDependency
8
 editor.fx.0.height=722
8
 editor.fx.0.height=722
9
 editor.fx.0.width=800
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
 package.divider.horizontal=0.6
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
 package.numDependencies=2
22
 package.numDependencies=2
23
 package.numTargets=4
23
 package.numTargets=4
24
 package.showExtends=true
24
 package.showExtends=true