12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
-
- public class TriangleUtilities {
- public static String getRow(int numberOfStars) {
- String str = "";
- for (int i=0; i<numberOfStars; i++){
- str += "*";
- }
- return str;
- }
-
- public static String getTriangle(int numberOfRows) {
- String rows="";
- for (int x=1; x<= numberOfRows; x++){
- for (int y=1; y<=x; y++) {
- rows+="*";
- }
- rows += "\n";
- }
- return rows;
- }
-
- public static String getSmallTriangle() {
- String small= "";
- for (int i=1; i<=4; i++){
- for (int j=1; j<=i; j++){
- small+="*";
- }
- small+="\n";
-
- }
- return small;
- }
-
- public static String getLargeTriangle() {
- String large= "";
- for (int i=1; i<10; i++){
- for (int j=1; j<=i; j++){
- large+="*";
- }
- large+="\n";
- }
- return large;
-
- }
- }
|