12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. public class TriangleUtilities {
  2. public static String getRow(int numberOfStars) {
  3. String str = "";
  4. for (int i=0; i<numberOfStars; i++){
  5. str += "*";
  6. }
  7. return str;
  8. }
  9. public static String getTriangle(int numberOfRows) {
  10. String rows="";
  11. for (int x=1; x<= numberOfRows; x++){
  12. for (int y=1; y<=x; y++) {
  13. rows+="*";
  14. }
  15. rows += "\n";
  16. }
  17. return rows;
  18. }
  19. public static String getSmallTriangle() {
  20. String small= "";
  21. for (int i=1; i<=4; i++){
  22. for (int j=1; j<=i; j++){
  23. small+="*";
  24. }
  25. small+="\n";
  26. }
  27. return small;
  28. }
  29. public static String getLargeTriangle() {
  30. String large= "";
  31. for (int i=1; i<10; i++){
  32. for (int j=1; j<=i; j++){
  33. large+="*";
  34. }
  35. large+="\n";
  36. }
  37. return large;
  38. }
  39. }