Skip to content

Commit cfbad1f

Browse files
Finish triangle exercises
1 parent cbf806a commit cfbad1f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Triangle.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44
public class Triangle {
55
public static void main(String[] args) {
66
easiestExerciseEver();
7+
drawHorizontalLine(8);
8+
drawVerticalLine(3);
9+
drawRightTriangle(3);
10+
}
11+
12+
private static void drawRightTriangle(int size) {
13+
for (int i = 0; i < size; i++) {
14+
drawHorizontalLine(i+1);
15+
}
16+
}
17+
18+
private static void drawVerticalLine(int size) {
19+
for (int i = 0; i < size; i++) {
20+
drawHorizontalLine(1);
21+
}
22+
}
23+
24+
private static void drawHorizontalLine(int size) {
25+
for (int i = 0; i < size; i++) {
26+
System.out.print("*");
27+
}
28+
System.out.println();
729
}
830

931
private static void easiestExerciseEver() {

0 commit comments

Comments
 (0)