Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. import sofia.micro.*;
  2. import sofia.util.Random;
  3.  
  4. //-------------------------------------------------------------------------
  5. /**
  6. * The environment in which the marbles
  7. * will roll around in.
  8. *
  9. * @author look its me!
  10. * @version 2017.06.26
  11. */
  12. public class Floor extends World
  13. {
  14. //~ Constructors ..........................................................
  15.  
  16. // ----------------------------------------------------------
  17. /**
  18. * Creates a new Floor object with a marble in each row.
  19. */
  20. public Floor()
  21. {
  22. this(true);
  23. }
  24.  
  25.  
  26. // ----------------------------------------------------------
  27. /**
  28. * Creates a new Floor object, with or without marbles.
  29. * This constructor is useful for writing software tests.
  30. * @param createBalls If true, the floor will be populated
  31. * with Marbles.
  32. */
  33. public Floor(boolean createMarbles)
  34. {
  35. super(12, 12, 60);
  36. if (createMarbles)
  37. {
  38. populate();
  39. }
  40. }
  41.  
  42. //~ Methods ...............................................................
  43.  
  44. // ----------------------------------------------------------
  45. /**
  46. * Add one marble for each y coordinate, at a random
  47. * x position.
  48. */
  49. private void populate()
  50. {
  51. int yValues = 12;
  52. for (int count = 0; count < yValues; count++)
  53. {
  54.  
  55. Marble keith = new Marble();
  56. int x = Random.nextInt(12);
  57. int y = count;
  58. add(keith, x, y);
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement