12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
-
-
- public class TriangleUtilities {
-
- public static String getRow(int numberOfStars) {
- int counter = 1;
- String triangle = "";
- String add = "*";
-
- for (int i = 1; i <= numberOfStars; i++){
- triangle = triangle + add;
- }
- return triangle;
- }
-
- public static String getTriangle(int numberOfRows) {
- int counter = 1;
- String triangle = "";
- String add = "*";
-
- for (int i = 1; i <= numberOfRows; i++){
-
- for (int y = 1; y <= counter; y++){
- triangle = triangle + add;
- }
- counter++;
- triangle = triangle + System.getProperty("line.separator");
- }
- return triangle;
- }
-
-
- public static String getSmallTriangle() {
- int width = 4;
- int counter = 1;
- String triangle = "";
- String add = "*";
-
- for (int i = 1; i <= width; i++){
-
- for (int y = 1; y <= counter; y++){
- triangle = triangle + add;
- }
- counter++;
- triangle = triangle + System.getProperty("line.separator");
- }
- return triangle;
- }
-
- public static String getLargeTriangle() {
- int width = 9;
- int counter = 1;
- String triangle = "";
- String add = "*";
-
- for (int i = 1; i <= width; i++){
-
- for (int y = 1; y <= counter; y++){
- triangle = triangle + add;
- }
- counter++;
- triangle = triangle + System.getProperty("line.separator");
- }
- return triangle;
- }
- }
|