1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
-
-
- public class TriangleUtilities {
-
- public static String getRow(int numberOfStars) {
- StringBuilder width = new StringBuilder();
- for (int i = 0; i< numberOfStars; i++){
- width.append("*");
- }
- return width.toString();
- }
-
- public static String getTriangle(int numberOfRows) {
- StringBuilder star = new StringBuilder();
- for (int i = 0; i< numberOfRows; i++){
- for (int a = 0; a <= i; a++){
- if (a<=i)
- star.append("*");
- }
- star.append("\n");
- }
- return star.toString();
- }
-
-
- public static String getSmallTriangle() {
- StringBuilder star = new StringBuilder();
- for (int i = 0; i<4; i++){
- for (int a = 0; a <= i; a++){
- if (a<=i)
- star.append("*");
- }
- star.append("\n");
- }
- return star.toString();
- }
-
- public static String getLargeTriangle() {
- StringBuilder star = new StringBuilder();
- for (int i = 0; i<9; i++){
- for (int a = 0; a <= i; a++){
- if (a<=i)
- star.append("*");
- }
- star.append("\n");
- }
- return star.toString();
- }
- }
|