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