Quellcode durchsuchen

my first saturday

Simran Bhutani vor 6 Jahren
Ursprung
Commit
a8c5d8b85c
5 geänderte Dateien mit 90 neuen und 42 gelöschten Zeilen
  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 Datei anzeigen

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

+ 2
- 0
WriteIFsTest.java Datei anzeigen

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

+ 51
- 17
WriteLoops.java Datei anzeigen

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

+ 2
- 0
WriteLoopsTest.java Datei anzeigen

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

+ 19
- 24
package.bluej Datei anzeigen

5
 dependency2.from=WriteIFsTest
5
 dependency2.from=WriteIFsTest
6
 dependency2.to=WriteIFs
6
 dependency2.to=WriteIFs
7
 dependency2.type=UsesDependency
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
 package.numDependencies=2
18
 package.numDependencies=2
23
 package.numTargets=4
19
 package.numTargets=4
24
 package.showExtends=true
20
 package.showExtends=true
25
 package.showUses=true
21
 package.showUses=true
26
-project.charset=UTF-8
27
 readme.height=58
22
 readme.height=58
28
 readme.name=@README
23
 readme.name=@README
29
 readme.width=47
24
 readme.width=47
44
 target2.width=100
39
 target2.width=100
45
 target2.x=140
40
 target2.x=140
46
 target2.y=360
41
 target2.y=360
42
+target3.association=WriteIFsTest
47
 target3.height=110
43
 target3.height=110
48
-target3.name=WriteIFsTest
44
+target3.name=WriteIFs
49
 target3.showInterface=false
45
 target3.showInterface=false
50
-target3.type=UnitTestTargetJunit4
46
+target3.type=ClassTarget
51
 target3.width=80
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
 target4.height=110
50
 target4.height=110
56
-target4.name=WriteIFs
51
+target4.name=WriteIFsTest
57
 target4.showInterface=false
52
 target4.showInterface=false
58
-target4.type=ClassTarget
53
+target4.type=UnitTestTargetJunit4
59
 target4.width=80
54
 target4.width=80
60
-target4.x=150
61
-target4.y=130
55
+target4.x=180
56
+target4.y=100