some code samples, various examples of simple modeling ideas and some minor algorithms.

TriangleTwo.java 726B

1234567891011121314151617181920212223242526272829303132333435363738
  1. class TriangleTwo {
  2. // Print a horizontal row of XTRIANGLES bottom-left right-angled triangles
  3. // of stars, each of size SIZE
  4. static final int SIZE=6;
  5. static final int XTRIANGLES=9;
  6. public void display()
  7. {
  8. this.display(XTRIANGLES, SIZE);
  9. }
  10. public void display(int num,int size)
  11. {
  12. for(int i=0;i<size;i++)
  13. {
  14. for(int k=0;k<num;k++)
  15. {
  16. int j;
  17. for(j=0;j<=i;j++)
  18. System.out.print("*");
  19. for(;j<size;j++)
  20. System.out.print(" ");
  21. }
  22. }
  23. System.out.println();
  24. }
  25. }
  26. /*
  27. }*/