12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
-
-
- public class TriangleUtilities {
-
- public static String getRow(int numberOfStars) {
- int counter = 0;
- String star = "*";
- for(int i = 1; i < numberOfStars; i++)
- {
- star = star + "*";
- // counter++; this was for me to count the *s fixing my code
-
- }
- //System.out.println("number: " + counter); ^
- return star;
- }
-
- public static String getTriangle(int numberOfRows) {
- int coumter;
- StringBuilder star = new StringBuilder();
-
- for(int i =1; i <= numberOfRows; i++)
- {
- for(int j=1;j<=i;j++)
- {
- star.append("*");
- }
- star.append("\n");
- }
-
- return star.toString();
-
- }
-
-
- public static String getSmallTriangle() {
-
- StringBuilder star = new StringBuilder();
-
- for(int i =1; i <= 4; i++)
- {
- for(int j=1;j<=i;j++)
- {
- star.append("*");
- }
- star.append("\n");
- }
-
- return star.toString();
- }
-
- public static String getLargeTriangle() {
- StringBuilder star = new StringBuilder();
-
- for(int i =1; i <= 9; i++)
- {
- for(int j=1;j<=i;j++)
- {
- star.append("*");
- }
- star.append("\n");
- }
-
- return star.toString();
- }
- }
|