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