12345678910111213141516171819202122232425262728293031323334353637 |
- import java.io.*;
- import java.util.*;
- import java.lang.*;
-
- public class TriangleUtilities {
- public static String getRow(int width) {
- String stars = "";
- for (int i=0; i<width; i++) {
- stars += "*";
- }
- return stars;
- }
-
- public static String getTriangle(int numberOfRows) {
- String stars = "";
-
- for (int i=0; i<numberOfRows; i++) {
-
- for (int b=0; b<=i; b++) {
- stars += "*";
-
- }
- stars+= "\n";
- }
-
- return stars;
- }
-
- public static String getSmallTriangle() {
- return getTriangle(4);
- }
-
- public static String getLargeTriangle() {
- return getTriangle(9);
- }
- }
|