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