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