|
@@ -1,11 +1,10 @@
|
|
1
|
+import java.util.*;
|
1
|
2
|
|
2
|
3
|
public class TriangleUtilities {
|
3
|
|
-
|
4
|
4
|
public static String getRow(int numberOfStars) {
|
5
|
5
|
String line = "";
|
6
|
|
-
|
7
|
|
- for(int i = 0; i <= numberOfStars; i++){
|
8
|
|
- line = "*"+ line;
|
|
6
|
+ for(int i = 0; i < numberOfStars; i++){
|
|
7
|
+ line += "*";
|
9
|
8
|
}
|
10
|
9
|
return line;
|
11
|
10
|
|
|
@@ -14,13 +13,13 @@ public class TriangleUtilities {
|
14
|
13
|
public static String getTriangle(int numberOfRows) {
|
15
|
14
|
|
16
|
15
|
String line = "";
|
17
|
|
-
|
18
|
|
- for(int i=0; i < numberOfRows; i++){
|
19
|
16
|
|
20
|
|
- for(int j=0; j <= i; j++){
|
21
|
|
- line = line + "*";
|
|
17
|
+ for(int i=1; i <= numberOfRows; i++){
|
|
18
|
+
|
|
19
|
+ for(int j=1; j <= i; j++){
|
|
20
|
+ line += "*";
|
22
|
21
|
}
|
23
|
|
- line = line + "/n";
|
|
22
|
+ line += "\n";
|
24
|
23
|
}
|
25
|
24
|
|
26
|
25
|
return line;
|
|
@@ -28,42 +27,31 @@ public class TriangleUtilities {
|
28
|
27
|
}
|
29
|
28
|
|
30
|
29
|
public static String getSmallTriangle() {
|
31
|
|
- return null;
|
32
|
|
- }
|
|
30
|
+ String line = "";
|
33
|
31
|
|
34
|
|
- public static String getLargeTriangle() {
|
35
|
|
- return null;
|
36
|
|
- }
|
|
32
|
+ for(int i=1; i <= 4; i++){
|
37
|
33
|
|
38
|
|
- public void squares()
|
39
|
|
- {
|
40
|
|
- int i,j;
|
41
|
|
- for(i=1; i<=5; i++)
|
42
|
|
- {
|
43
|
|
- for(j=1; j<=4; j++)
|
44
|
|
- {
|
45
|
|
- System.out.print("*");
|
|
34
|
+ for(int j=1; j <= i; j++){
|
|
35
|
+ line += "*";
|
46
|
36
|
}
|
47
|
|
- System.out.println(" ");
|
|
37
|
+ line += "\n";
|
48
|
38
|
}
|
|
39
|
+
|
|
40
|
+ return line;
|
|
41
|
+
|
49
|
42
|
}
|
|
43
|
+ public static String getLargeTriangle() {
|
|
44
|
+ String line = "";
|
50
|
45
|
|
51
|
|
- public void trying()
|
52
|
|
- {
|
53
|
|
- int i,j,k;
|
54
|
|
- for(i=1; i<=5; i++)
|
55
|
|
- {
|
56
|
|
- for(j=4; j>=i; j--)
|
57
|
|
- {
|
58
|
|
- System.out.print(" ");
|
59
|
|
- }
|
60
|
|
- for(k=1; k<=(2+j-1); k++)
|
61
|
|
- {
|
62
|
|
- System.out.print("*");
|
63
|
|
- }
|
64
|
|
- System.out.println("");
|
|
46
|
+ for(int i=1; i <10; i++){
|
|
47
|
+ for(int j=1; j <= i; j++){
|
|
48
|
+ line += "*";
|
65
|
49
|
}
|
|
50
|
+ line += "\n";
|
66
|
51
|
}
|
|
52
|
+
|
|
53
|
+ return line;
|
67
|
54
|
}
|
68
|
55
|
|
|
56
|
+}
|
69
|
57
|
|