12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. public class TriangleUtilities {
  2. public static String getRow(int numberOfStars) {
  3. int counter = 0;
  4. String star = "*";
  5. for(int i = 1; i < numberOfStars; i++)
  6. {
  7. star = star + "*";
  8. // counter++; this was for me to count the *s fixing my code
  9. }
  10. //System.out.println("number: " + counter); ^
  11. return star;
  12. }
  13. public static String getTriangle(int numberOfRows) {
  14. int coumter;
  15. StringBuilder star = new StringBuilder();
  16. for(int i =1; i <= numberOfRows; i++)
  17. {
  18. for(int j=1;j<=i;j++)
  19. {
  20. star.append("*");
  21. }
  22. star.append("\n");
  23. }
  24. return star.toString();
  25. }
  26. public static String getSmallTriangle() {
  27. StringBuilder star = new StringBuilder();
  28. for(int i =1; i <= 4; i++)
  29. {
  30. for(int j=1;j<=i;j++)
  31. {
  32. star.append("*");
  33. }
  34. star.append("\n");
  35. }
  36. return star.toString();
  37. }
  38. public static String getLargeTriangle() {
  39. StringBuilder star = new StringBuilder();
  40. for(int i =1; i <= 9; i++)
  41. {
  42. for(int j=1;j<=i;j++)
  43. {
  44. star.append("*");
  45. }
  46. star.append("\n");
  47. }
  48. return star.toString();
  49. }
  50. }