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