소스 검색

Added comments to triangleUtilities and tableUtilities

Trinh Tong 6 년 전
부모
커밋
13155c4cb9
3개의 변경된 파일46개의 추가작업 그리고 20개의 파일을 삭제
  1. 12
    0
      TableUtilities.java
  2. 16
    2
      TriangleUtilities.java
  3. 18
    18
      package.bluej

+ 12
- 0
TableUtilities.java 파일 보기

9
         return getMultiplicationTable(10);
9
         return getMultiplicationTable(10);
10
     }
10
     }
11
 
11
 
12
+    /**
13
+     * The two above methods, small/large MultiplicationTable, call on the
14
+     * getMultiplicationTable to produce the desired result. 
15
+     * 
16
+     * Originally, the same code was used for each method, and the 
17
+     * "tableSize" parameter was just the req'd table size (ie. 5).
18
+     * 
19
+     * However, since each method returns the same format, calling on 
20
+     * getMultiplicationTable becomes more efficient and cuts down on 
21
+     * repeat code.
22
+     * 
23
+     */
12
     public static String getMultiplicationTable(int tableSize) {
24
     public static String getMultiplicationTable(int tableSize) {
13
         StringBuilder multiTable = new StringBuilder();
25
         StringBuilder multiTable = new StringBuilder();
14
         // nested for loop
26
         // nested for loop

+ 16
- 2
TriangleUtilities.java 파일 보기

1
- import java.util.*;
2
 
1
 
3
-public class TriangleUtilities {
4
 
2
 
3
+
4
+import java.util.*;
5
+
6
+public class TriangleUtilities {
7
+    /**
8
+     * method getRow uses a for loop to create 1 row of stars with a given
9
+     * number of stars as the parameter (numberOfStars)
10
+     */
5
     public static String getRow(int numberOfStars) {
11
     public static String getRow(int numberOfStars) {
6
         // Use StringBuilder and a loop
12
         // Use StringBuilder and a loop
7
         
13
         
14
         return stars.toString();
20
         return stars.toString();
15
     }
21
     }
16
     
22
     
23
+    /**
24
+     * method getTriangle uses a nested for loop to build the triangle of stars 
25
+     * with StringBuilder. 
26
+     * 
27
+     * Since getSmallTriangle and getLargeTriangle are essentially fixed sizes of 
28
+     * the star triangles, I call the getTriangle method with the parameter 
29
+     * "numberOfRows"
30
+     */ 
17
     public static String getTriangle(int numberOfRows) {
31
     public static String getTriangle(int numberOfRows) {
18
         StringBuilder stars = new StringBuilder();
32
         StringBuilder stars = new StringBuilder();
19
         
33
         

+ 18
- 18
package.bluej 파일 보기

1
 #BlueJ package file
1
 #BlueJ package file
2
-dependency1.from=NumberUtilitiesTest
3
-dependency1.to=NumberUtilities
2
+dependency1.from=TableUtilitiesTest
3
+dependency1.to=TableUtilities
4
 dependency1.type=UsesDependency
4
 dependency1.type=UsesDependency
5
 dependency2.from=TriangleUtilitiesTest
5
 dependency2.from=TriangleUtilitiesTest
6
 dependency2.to=TriangleUtilities
6
 dependency2.to=TriangleUtilities
7
 dependency2.type=UsesDependency
7
 dependency2.type=UsesDependency
8
-dependency3.from=TableUtilitiesTest
9
-dependency3.to=TableUtilities
8
+dependency3.from=NumberUtilitiesTest
9
+dependency3.to=NumberUtilities
10
 dependency3.type=UsesDependency
10
 dependency3.type=UsesDependency
11
 editor.fx.0.height=722
11
 editor.fx.0.height=722
12
-editor.fx.0.width=800
13
-editor.fx.0.x=537
12
+editor.fx.0.width=897
13
+editor.fx.0.x=471
14
 editor.fx.0.y=28
14
 editor.fx.0.y=28
15
-objectbench.height=164
16
-objectbench.width=484
15
+objectbench.height=165
16
+objectbench.width=426
17
 package.divider.horizontal=0.6
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
18
+package.divider.vertical=0.7546362339514978
19
+package.editor.height=522
20
+package.editor.width=324
21
+package.editor.x=62
22
+package.editor.y=86
23
 package.frame.height=759
23
 package.frame.height=759
24
-package.frame.width=508
24
+package.frame.width=450
25
 package.numDependencies=3
25
 package.numDependencies=3
26
 package.numTargets=6
26
 package.numTargets=6
27
 package.showExtends=true
27
 package.showExtends=true
37
 target1.showInterface=false
37
 target1.showInterface=false
38
 target1.type=UnitTestTargetJunit4
38
 target1.type=UnitTestTargetJunit4
39
 target1.width=110
39
 target1.width=110
40
-target1.x=100
41
-target1.y=270
40
+target1.x=130
41
+target1.y=310
42
 target2.height=50
42
 target2.height=50
43
 target2.name=TriangleUtilitiesTest
43
 target2.name=TriangleUtilitiesTest
44
 target2.showInterface=false
44
 target2.showInterface=false
52
 target3.showInterface=false
52
 target3.showInterface=false
53
 target3.type=ClassTarget
53
 target3.type=ClassTarget
54
 target3.width=110
54
 target3.width=110
55
-target3.x=70
56
-target3.y=300
55
+target3.x=100
56
+target3.y=340
57
 target4.association=NumberUtilitiesTest
57
 target4.association=NumberUtilitiesTest
58
 target4.height=50
58
 target4.height=50
59
 target4.name=NumberUtilities
59
 target4.name=NumberUtilities