Browse Source

my first saturday

Simran Bhutani 6 years ago
parent
commit
a8c5d8b85c
5 changed files with 90 additions and 42 deletions
  1. 16
    1
      WriteIFs.java
  2. 2
    0
      WriteIFsTest.java
  3. 51
    17
      WriteLoops.java
  4. 2
    0
      WriteLoopsTest.java
  5. 19
    24
      package.bluej

+ 16
- 1
WriteIFs.java View File

@@ -1,3 +1,5 @@
1
+package FirstSaturday;
2
+
1 3
 
2 4
 /**
3 5
  * Write a description of class WriteIFs here.
@@ -9,12 +11,23 @@ public class WriteIFs
9 11
 {
10 12
  
11 13
     public void playerDied(boolean player1) {
14
+        
15
+        
12 16
         // Write an IF statement that checks “player1.isAlive()” 
13 17
         // and if that’s false, calls “displayGameOver(player1)”
14 18
      
15 19
     }
16 20
     
17 21
     public String thermoSTAT(int room) {
22
+        if(room<70)
23
+         {
24
+            System.out.println("heat on");
25
+         }
26
+         
27
+        else
28
+        {
29
+           System.out.println("cool on");
30
+        }
18 31
         // Write an IF statement that checks the 
19 32
         // “temperature(room)” and if that check is less than 70, 
20 33
         // calls “heatOn()” else calls “coolOn()”
@@ -34,6 +47,7 @@ public class WriteIFs
34 47
     }
35 48
 
36 49
     public void checkFuel(double fuelLevel) {
50
+        
37 51
         // Write an IF statement that checks “fuelLevel” 
38 52
         // and if that check is less than 0.08, calls “refuel()”
39 53
 
@@ -46,7 +60,8 @@ public class WriteIFs
46 60
      * 
47 61
      * 
48 62
      * instance variables
49
-     * / 
63
+     */ 
64
+    
50 65
    int x;
51 66
    int tt_t;
52 67
    int tt_s;

+ 2
- 0
WriteIFsTest.java View File

@@ -1,3 +1,5 @@
1
+package FirstSaturday;
2
+
1 3
 
2 4
 
3 5
 import static org.junit.Assert.*;

+ 51
- 17
WriteLoops.java View File

@@ -1,3 +1,5 @@
1
+package FirstSaturday;
2
+
1 3
 import com.sun.org.apache.xpath.internal.SourceTree;
2 4
 
3 5
 import java.awt.SystemTray;
@@ -17,10 +19,13 @@ public class WriteLoops {
17 19
 
18 20
     public int oneToFive() {
19 21
         int w = 0;
20
-
22
+          for(int i=1;i<=5;i++)
23
+          {
24
+             w = w + 1;
25
+            }
21 26
         // Write a FOR loop that counts from 1 to 10.
22 27
             // calling
23
-            w = w + 1;
28
+           
24 29
             // each time through the loop
25 30
 
26 31
         // this will tell the test how many times the loop executed.
@@ -29,10 +34,13 @@ public class WriteLoops {
29 34
 
30 35
     public int oneToTen() {
31 36
         int w = 0;
32
-
37
+         for(int i=1;i<=10;i++)
38
+          {
39
+             w = w + 1;
40
+            }
33 41
         // Write a FOR loop that counts from 1 to 10.
34 42
         // calling
35
-        w = w + 1;
43
+        
36 44
         // each time through the loop
37 45
         
38 46
         return w;
@@ -40,10 +48,13 @@ public class WriteLoops {
40 48
 
41 49
     public int startAtTwentyOne() {
42 50
         int w = 0;
43
-
51
+          for(int i=21;i<=31;i++)
52
+          {
53
+             w = w + 1;
54
+            }
44 55
         // Write a FOR loop that makes 10 iterations, start at 21.
45 56
         // calling
46
-        w = w + 1;
57
+        
47 58
         // each time through the loop
48 59
         
49 60
         return w;
@@ -51,10 +62,13 @@ public class WriteLoops {
51 62
 
52 63
     public int countDown() {
53 64
         int w = 0;
54
-
65
+             for(int i=100;i<=0;i--)
66
+          {
67
+             w = w + 1;
68
+            }
55 69
         // Write a FOR loop that counts down from 100 to 0.
56 70
         // calling
57
-        w = w + 1;
71
+       
58 72
         // each time through the loop
59 73
         
60 74
         return w;
@@ -62,20 +76,26 @@ public class WriteLoops {
62 76
 
63 77
     public int byTwoTo32() {
64 78
         int w = 0;
65
-
79
+         for(int i=0;i<=32;i=i+2)
80
+          {
81
+             w = w + 1;
82
+            }
66 83
         // Write a FOR loop from 0 to 32 by 2s.
67 84
         // calling
68
-        w = w + 1;
85
+        
69 86
         // each time through the loop
70 87
         return w;
71 88
     }
72 89
 
73 90
     public int countDownFrom5000() {
74 91
         int w = 0;
75
-
92
+             for(int i=1;i<5001;i=i+11)
93
+          {
94
+             w = w + 1;
95
+            }
76 96
         // Write a FOR loop from 1 to less than 5001 by 11s.
77 97
         // calling
78
-        w = w + 1;
98
+        
79 99
         // each time through the loop
80 100
         
81 101
         return w;
@@ -83,11 +103,18 @@ public class WriteLoops {
83 103
 
84 104
     public int nestedFors() {
85 105
         int w = 0;
86
-
106
+             for(int i=0;i<20;i++)
107
+          {
108
+               for(int j=0; j<=4;j++)
109
+          {
110
+             w = w + 1;
111
+            }
112
+            
113
+            }
87 114
         // Write a nested FOR loop(s), where one counts from
88 115
         // 0 to less than 20 and the inner one counts from 0 to 4
89 116
                 // calling
90
-                w = w + 1;
117
+               
91 118
                 // each time through the inner loop
92 119
 
93 120
         return w;
@@ -95,14 +122,21 @@ public class WriteLoops {
95 122
 
96 123
     public int helloZipCode() {
97 124
         int w = 0;
98
-
125
+             for(int i=5;i<=105;i++)
126
+          {
127
+              if(i>51)
128
+              {
129
+                System.out.println("Hello Zipcode");
130
+                }
131
+             
132
+            }
99 133
         // Write a FOR loop that counts from 5 to 105. Put an IF
100 134
         // statement inside the loop that checks the
101 135
         // loop index counter and if it’s greater than 51,
102 136
         // prints “Hello Zipcode” instead of the statement w = w + 1;
103 137
 
104 138
                 // calling
105
-                w = w + 1;
139
+                
106 140
             // each time through the inner loop
107 141
         
108 142
         return w;
@@ -131,7 +165,7 @@ public class WriteLoops {
131 165
     // After the loop is done, print “Honey, I’m Home!”
132 166
     public int driveHome() {
133 167
         int w = 0;
134
-
168
+            
135 169
         // you need to use a .equals for two Strings.
136 170
 
137 171
             // calling

+ 2
- 0
WriteLoopsTest.java View File

@@ -1,3 +1,5 @@
1
+package FirstSaturday;
2
+
1 3
 
2 4
 
3 5
 import static org.junit.Assert.*;

+ 19
- 24
package.bluej View File

@@ -5,25 +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
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
8
+objectbench.height=97
9
+objectbench.width=563
10
+package.divider.horizontal=0.6404494382022472
11
+package.divider.vertical=0.8620689655172413
12
+package.editor.height=643
13
+package.editor.width=784
14
+package.editor.x=14
15
+package.editor.y=31
16
+package.frame.height=812
17
+package.frame.width=910
22 18
 package.numDependencies=2
23 19
 package.numTargets=4
24 20
 package.showExtends=true
25 21
 package.showUses=true
26
-project.charset=UTF-8
27 22
 readme.height=58
28 23
 readme.name=@README
29 24
 readme.width=47
@@ -44,18 +39,18 @@ target2.type=ClassTarget
44 39
 target2.width=100
45 40
 target2.x=140
46 41
 target2.y=360
42
+target3.association=WriteIFsTest
47 43
 target3.height=110
48
-target3.name=WriteIFsTest
44
+target3.name=WriteIFs
49 45
 target3.showInterface=false
50
-target3.type=UnitTestTargetJunit4
46
+target3.type=ClassTarget
51 47
 target3.width=80
52
-target3.x=180
53
-target3.y=100
54
-target4.association=WriteIFsTest
48
+target3.x=150
49
+target3.y=130
55 50
 target4.height=110
56
-target4.name=WriteIFs
51
+target4.name=WriteIFsTest
57 52
 target4.showInterface=false
58
-target4.type=ClassTarget
53
+target4.type=UnitTestTargetJunit4
59 54
 target4.width=80
60
-target4.x=150
61
-target4.y=130
55
+target4.x=180
56
+target4.y=100