12345678910111213141516171819202122232425262728293031323334353637 |
-
- 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 triangle = new StringBuilder();
-
- for(int i = 1; i <= numberOfRows; i++) {
- String answer = getRow(i);
-
- triangle.append(answer + "\n");
-
- }
-
- return triangle.toString();
- }
-
-
- public static String getSmallTriangle() {
- return getTriangle(4);
- }
-
- public static String getLargeTriangle() {
- return getTriangle(9);
- }
- }
|