#31 Lewis did this

Открыто
LewisDominguez хочет смерджить 1 коммит(ов) из LewisDominguez/CR-MicroLabs-Loops-NumbersTrianglesTables:master в master
5 измененных файлов: 88 добавлений и 38 удалений
  1. Двоичные данные
      .DS_Store
  2. 55
    14
      NumberUtilities.java
  3. 0
    0
      README.TXT
  4. 15
    6
      TriangleUtilities.java
  5. 18
    18
      package.bluej

Двоичные данные
.DS_Store Просмотреть файл


+ 55
- 14
NumberUtilities.java Просмотреть файл

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

+ 0
- 0
README.TXT Просмотреть файл


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

@@ -1,18 +1,27 @@
1
- 
2 1
 
3 2
 public class TriangleUtilities {
4
-
5 3
     public static String getRow(int numberOfStars) {
6
-        return null;
4
+        StringBuilder row = new StringBuilder();
5
+        String star = "*";
6
+        for (int i = 0; i < numberOfStars; i++) {
7
+            row.append(star);
8
+
9
+        }
10
+        return row.toString();
7 11
     }
8
-    
12
+
9 13
     public static String getTriangle(int numberOfRows) {
10
-        return null;
14
+        StringBuilder row = new StringBuilder();
15
+        String star = "*\n";
16
+        for (int i = 0; i < numberOfRows; i++) {
17
+            row.append(star);
18
+        }
19
+        return row.toString();
11 20
     }
12 21
 
13
-
14 22
     public static String getSmallTriangle() {
15 23
         return null;
24
+
16 25
     }
17 26
 
18 27
     public static String getLargeTriangle() {

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

@@ -1,26 +1,26 @@
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
12
-editor.fx.0.width=800
13
-editor.fx.0.x=537
14
-editor.fx.0.y=28
15
-objectbench.height=164
11
+editor.fx.0.height=0
12
+editor.fx.0.width=0
13
+editor.fx.0.x=0
14
+editor.fx.0.y=0
15
+objectbench.height=156
16 16
 objectbench.width=484
17 17
 package.divider.horizontal=0.6
18
-package.divider.vertical=0.7560627674750356
19
-package.editor.height=523
18
+package.divider.vertical=0.7552552552552553
19
+package.editor.height=496
20 20
 package.editor.width=382
21
-package.editor.x=20
22
-package.editor.y=57
23
-package.frame.height=759
21
+package.editor.x=30
22
+package.editor.y=23
23
+package.frame.height=724
24 24
 package.frame.width=508
25 25
 package.numDependencies=3
26 26
 package.numTargets=6
@@ -43,7 +43,7 @@ target2.height=50
43 43
 target2.name=TriangleUtilitiesTest
44 44
 target2.showInterface=false
45 45
 target2.type=UnitTestTargetJunit4
46
-target2.width=120
46
+target2.width=130
47 47
 target2.x=100
48 48
 target2.y=160
49 49
 target3.association=TableUtilitiesTest
@@ -59,14 +59,14 @@ target4.height=50
59 59
 target4.name=NumberUtilities
60 60
 target4.showInterface=false
61 61
 target4.type=ClassTarget
62
-target4.width=120
62
+target4.width=130
63 63
 target4.x=80
64 64
 target4.y=70
65 65
 target5.height=50
66 66
 target5.name=NumberUtilitiesTest
67 67
 target5.showInterface=false
68 68
 target5.type=UnitTestTargetJunit4
69
-target5.width=120
69
+target5.width=130
70 70
 target5.x=110
71 71
 target5.y=40
72 72
 target6.association=TriangleUtilitiesTest
@@ -74,6 +74,6 @@ target6.height=50
74 74
 target6.name=TriangleUtilities
75 75
 target6.showInterface=false
76 76
 target6.type=ClassTarget
77
-target6.width=120
77
+target6.width=130
78 78
 target6.x=70
79 79
 target6.y=190