Advertisement
mcnealk

Project3

Oct 17th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1.  
  2. /**
  3. * Write a description of class Project3 here.
  4. *
  5. * @author Kailey McNeal
  6. * @version 10-15-14
  7. * Project 3 p231
  8. */
  9. import java.awt.*;
  10. import java.applet.*;
  11. public class Project3 extends Applet
  12. {
  13. public void paint(Graphics g)
  14. {
  15. printTile(g,0,0,1,20,5);
  16. printTile(g,45,120,10,5,3);
  17. printTile(g,200,45,5,10,4);
  18. }
  19. public static void printTile(Graphics g, int x, int y, int numoftiles, int squaresize, int numgrids)
  20. {
  21. for (int i=0;i<numoftiles;i++)
  22. {
  23. for(int j=0;j<numoftiles;j++)
  24. {
  25. printSquare(g, x+1*squaresize*numgrids, y+j*squaresize*numgrids, squaresize, numgrids);
  26. }
  27. }
  28. }
  29. public static void printSquare(Graphics g, int x, int y, int squaresize, int numgrids)
  30. {
  31. g.setColor(Color.red);
  32. for(int i=0; i<numgrids;i++)
  33. {
  34. for(int j=i%2; j<numgrids; j+=2)
  35. {
  36. g.fillRect(x+i*squaresize, y+j*squaresize, squaresize, squaresize);
  37. }
  38. }
  39. g.setColor(Color.black);
  40. g.drawRect(x, y, squaresize*numgrids, squaresize*numgrids);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement