12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
-
- public class TriangleUtilities {
- public static String getRow(int numberOfStars) {
- StringBuilder triangle = new StringBuilder();
-
- for(int i=0; i<numberOfStars; i ++){
- triangle.append("*");
- }
-
- return triangle.toString();
- }
-
- public static String getTriangle(int numberOfRows) {
- StringBuilder triangle = new StringBuilder();
-
- for(int row=1; row<=numberOfRows; row++){
- for(int i=1; i<=row; i++){
- triangle.append("*");
- }
- triangle.append("\n");
- }
-
- return triangle.toString();
- }
-
- public static String getSmallTriangle() {
- StringBuilder triangle = new StringBuilder();
-
- for(int row=1; row<=4; row++){
- for(int i=1; i<=row; i++){
- triangle.append("*");
- }
- triangle.append("\n");
- }
-
- return triangle.toString();
- }
-
- public static String getLargeTriangle() {
- StringBuilder triangle = new StringBuilder();
-
- for(int row=1; row<=10-1; row++){
- for(int i=1; i<=row; i++){
- triangle.append("*");
- }
- triangle.append("\n");
- }
-
- return triangle.toString();
- }
- }
|