123456789101112131415161718192021222324252627282930313233 |
-
-
- public class TriangleUtilities {
-
-
- public static String getRow(int numberOfStars) {
- StringBuilder row = new StringBuilder();
- for (int i = 0; i < numberOfStars; i++){
- row = row.append('*');
- }
- System.out.println(row);
- return row.toString();
- }
-
- public static String getTriangle(int numberOfRows) {
- StringBuilder triangle = new StringBuilder();
- for (int i = 0; i < numberOfRows; i++) {
- String currRow = getRow(i + 1);
- triangle.append(currRow + "\n");
- }
- return triangle.toString();
- }
-
-
- public static String getSmallTriangle() {
- return getTriangle(4);
- }
-
- public static String getLargeTriangle() {
- return getTriangle(9);
- }
- }
|