浏览代码

interim changes

Donna Jacobs 6 年前
父节点
当前提交
e0894d642b
共有 4 个文件被更改,包括 56 次插入24 次删除
  1. 38
    7
      NumberUtilities.java
  2. 0
    0
      README.TXT
  3. 1
    0
      TriangleUtilities.java
  4. 17
    17
      package.bluej

+ 38
- 7
NumberUtilities.java 查看文件

@@ -3,30 +3,61 @@
3 3
 
4 4
 public class NumberUtilities {
5 5
     
6
-    public static String getRange(int start) {
7
-        return null;
6
+    public static String getRange(int stop) {
7
+        StringBuilder sb = new StringBuilder();
8
+        for(int i=0; i<stop; i++) {
9
+            sb.append(i);
10
+            
11
+        }
12
+        return sb.toString();
13
+       
8 14
     }
9 15
     
10 16
     public static String getRange(int start, int stop) {
11
-        return null;
17
+        StringBuilder sb2 = new StringBuilder();
18
+        for(int i = start; i < stop; i++) {
19
+            sb2.append(i);
20
+        }
21
+        return sb2.toString();
12 22
     }
13 23
 
14 24
 
15 25
     public static String getRange(int start, int stop, int step) {
16
-        return null;
26
+        StringBuilder sb3 = new StringBuilder();
27
+        for(int i=start; i<stop; i+=step) {
28
+            sb3.append(i);
29
+        }
30
+        return sb3.toString();
17 31
     }
18 32
     
19 33
     public static String getEvenNumbers(int start, int stop) {
20
-        return null;
34
+        StringBuilder sb4 = new StringBuilder();
35
+        for(int i = start; i < stop; i++) {
36
+            if(i%2==0) {
37
+            sb4.append(i);}
21 38
     }
39
+        return sb4.toString();
40
+    }
41
+
22 42
 
23 43
 
24 44
     public static String getOddNumbers(int start, int stop) {
25
-        return null;
45
+        StringBuilder sb5 = new StringBuilder();
46
+        for(int i = start; i < stop; i++) {
47
+            if(i%2!=0) {
48
+            sb5.append(i);}
49
+    }
50
+        return sb5.toString();
26 51
     }
27 52
 
28 53
 
29 54
     public static String getExponentiations(int start, int stop, int exponent) {
30
-        return null;
55
+        StringBuilder sb6 = new StringBuilder();
56
+        int exp = exponent;
57
+        int answer = 0;
58
+        for(int i=start; i<=stop; i++) {
59
+            sb6.append((int)Math.pow(i,exp));
60
+        }
61
+        return sb6.toString();
31 62
     }
32 63
 }

+ 0
- 0
README.TXT 查看文件


+ 1
- 0
TriangleUtilities.java 查看文件

@@ -3,6 +3,7 @@
3 3
 public class TriangleUtilities {
4 4
 
5 5
     public static String getRow(int numberOfStars) {
6
+        
6 7
         return null;
7 8
     }
8 9
     

+ 17
- 17
package.bluej 查看文件

@@ -1,27 +1,27 @@
1 1
 #BlueJ package file
2
-dependency1.from=NumberUtilitiesTest
3
-dependency1.to=NumberUtilities
2
+dependency1.from=TableUtilitiesTest
3
+dependency1.to=TableUtilities
4 4
 dependency1.type=UsesDependency
5 5
 dependency2.from=TriangleUtilitiesTest
6 6
 dependency2.to=TriangleUtilities
7 7
 dependency2.type=UsesDependency
8
-dependency3.from=TableUtilitiesTest
9
-dependency3.to=TableUtilities
8
+dependency3.from=NumberUtilitiesTest
9
+dependency3.to=NumberUtilities
10 10
 dependency3.type=UsesDependency
11
-editor.fx.0.height=722
11
+editor.fx.0.height=709
12 12
 editor.fx.0.width=800
13
-editor.fx.0.x=537
14
-editor.fx.0.y=28
15
-objectbench.height=164
16
-objectbench.width=484
17
-package.divider.horizontal=0.6
18
-package.divider.vertical=0.7560627674750356
19
-package.editor.height=523
20
-package.editor.width=382
21
-package.editor.x=20
22
-package.editor.y=57
23
-package.frame.height=759
24
-package.frame.width=508
13
+editor.fx.0.x=475
14
+editor.fx.0.y=23
15
+objectbench.height=152
16
+objectbench.width=424
17
+package.divider.horizontal=0.6002785515320335
18
+package.divider.vertical=0.7557603686635944
19
+package.editor.height=485
20
+package.editor.width=612
21
+package.editor.x=427
22
+package.editor.y=23
23
+package.frame.height=709
24
+package.frame.width=738
25 25
 package.numDependencies=3
26 26
 package.numTargets=6
27 27
 package.showExtends=true