Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import java.awt.Color;
  2.  
  3. public class Bubble
  4. {
  5. // instance variables
  6. Color c;
  7. int r;//radius
  8. int xSpeed;
  9. int ySpeed;
  10. boolean show;//is visible
  11. int x;
  12. int y;
  13.  
  14. public Bubble()
  15. {
  16. // Initialize instance variables
  17. int red = produceRandom(0,255);
  18. int g =produceRandom(0,255);
  19. int b = produceRandom(0,255);
  20. xSpeed = produceRandom(-10,10);
  21. ySpeed = produceRandom(-10,10);
  22. c = new Color(red,g,b);
  23. r = produceRandom(2,25);
  24. show = false;
  25. }
  26.  
  27.  
  28. public void setLocation(int x, int y){
  29. this.x = x;
  30. this.y = y;
  31. show = true;
  32. }
  33.  
  34. public int produceRandom(int min, int max)
  35. {
  36. // put your code here
  37. return (int)(Math.random() * ((max - min) + 1)) + min;
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement