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