Guest User

Untitled

a guest
Aug 1st, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public static void flagOfSwitzerland (Graphics g, int numDots)
  2. {
  3. g.setColor(Color.red);
  4. g.fillRect(0,0,1000,650);
  5. for (int d = 1; d <= numDots; d++)
  6. {
  7. int x = rand.nextInt(1000); // random x value of each dot
  8. int y = rand.nextInt(650); // random y value of each dot
  9.  
  10. if (x >= 400 && x < 800) // middle stripe requires compound condition
  11. g.setColor(Color.white);
  12. else g.setColor(Color.red);
  13.  
  14. if (y >= 260 && y < 520) // middle stripe requires compound condition
  15. g.setColor(Color.white);
  16. else g.setColor(Color.red);
  17.  
  18. g.fillRect(x,y,3,3);
  19. }
  20. showName(g,"Switzerland");
  21. }
Advertisement
Add Comment
Please, Sign In to add comment