Mexi Liang vor 6 Jahren
Ursprung
Commit
870ca61959
3 geänderte Dateien mit 45 neuen und 27 gelöschten Zeilen
  1. BIN
      .DS_Store
  2. 29
    11
      TableUtilities.java
  3. 16
    16
      package.bluej

BIN
.DS_Store Datei anzeigen


+ 29
- 11
TableUtilities.java Datei anzeigen

@@ -2,30 +2,48 @@
2 2
 
3 3
 public class TableUtilities {
4 4
     public static String getSmallMultiplicationTable() {
5
+        StringBuilder anw = new StringBuilder();
6
+        int tableSize = 5;
5 7
         
8
+        String pattern = "%4d";
9
+        for (int i=1;i<=5;i++){
10
+            for (int j=1;j<=5;j++){
11
+            
12
+            anw.append(String.format(pattern,i*j));
13
+            }
14
+            anw.append("\n");
15
+        }
6 16
         
7
-        return null;
17
+        return anw.toString();
8 18
     }
9 19
 
10 20
     public static String getLargeMultiplicationTable() {
11
-        return null;
21
+        StringBuilder anw = new StringBuilder();
22
+        int tableSize = 10;
23
+        String pattern = "%4d";
24
+        for (int i=1;i<=10;i++){
25
+            for (int j=1;j<=10;j++){
26
+            
27
+                anw.append(String.format(pattern,i*j));
28
+               
29
+            }
30
+            anw.append("\n");
31
+           
32
+        }
33
+        
34
+        return anw.toString();
12 35
     }
13 36
 
14 37
     public static String getMultiplicationTable(int tableSize) {
15 38
         StringBuilder anw = new StringBuilder();
16
-        
17
-        
18
-        for (int i=1;i<=tableSize;i++){
19
-        anw.append(i);
20
-        }
21
-        
39
+        String pattern = "%4d";
22 40
         for (int i=1;i<=tableSize;i++){
23 41
             for (int j=2;j<=tableSize;i++){
24
-                
42
+                anw.append(String.format(pattern,i*j));
25 43
             }
26
-            
44
+            anw.append("\n");
27 45
             
28 46
         }
29
-        return null;
47
+        return anw.toString();
30 48
     }
31 49
 }

+ 16
- 16
package.bluej Datei anzeigen

@@ -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
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
13
+editor.fx.0.x=480
14
+editor.fx.0.y=23
15
+objectbench.height=152
16 16
 objectbench.width=484
17 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
18
+package.divider.vertical=0.7557603686635944
19
+package.editor.height=485
20
+package.editor.width=383
21
+package.editor.x=146
22
+package.editor.y=23
23
+package.frame.height=709
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
@@ -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