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