public class TriangleUtilities { public static String getRow(int numberOfStars) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < numberOfStars; i++) { sb = sb.append("*"); } return sb.toString(); } public static String getTriangle(int numberOfRows) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < numberOfRows; i++) { for (int j = 0; j <= i; j++) { sb.append("*"); } sb.append("\n"); } return sb.toString(); } public static String getSmallTriangle() { StringBuilder sb = new StringBuilder(); int count = 4; for (int i = 0; i < count; i++) { for (int j = 0; j <= i; j++) { sb.append("*"); } sb.append("\n"); } System.out.print(sb); return sb.toString(); } public static String getLargeTriangle() { StringBuilder sb = new StringBuilder(); int count = 9; for (int i = 0; i < count; i++) { for (int j = 0; j <= i; j++) { sb.append("*"); } sb.append("\n"); } System.out.print(sb); return sb.toString(); } }