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