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