12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
-
-
- public class TriangleUtilities {
-
- public static String getRow(int numberOfStars) {
- String result="";
- for(int i=1;i<= numberOfStars;i++)
- {
- result=result+ "*";
- }
- return result;
- }
-
- public static String getTriangle(int numberOfRows) {
- String result="";
- for(int line=1;line<=numberOfRows;line++)
- {
- for( int j =1 ; j<=line; j++ )
- {
- result = result+"*" ;
- }
- result= result+ "\n";
- }
- return result;
-
- }
-
-
- public static String getSmallTriangle() {
- String result="";
- for(int line=1;line<=4;line++)
- {
- for( int j =1 ; j<=line; j++ )
- {
- result = result+"*" ;
- }
- result= result+ "\n"; // \n to change line
- }
- return result;
- }
-
- public static String getLargeTriangle() {
- String result="";
- for(int line=1;line<=9;line++)
- {
- for( int j =1 ; j<=line; j++ )
- {
- result = result+"*" ;
- }
- result= result+ "\n";
- }
- return result;
- }
- }
|