Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sofia.micro.*;
- import sofia.util.Random;
- //-------------------------------------------------------------------------
- /**
- * The environment in which the marbles
- * will roll around in.
- *
- * @author look its me!
- * @version 2017.06.26
- */
- public class Floor extends World
- {
- //~ Constructors ..........................................................
- // ----------------------------------------------------------
- /**
- * Creates a new Floor object with a marble in each row.
- */
- public Floor()
- {
- this(true);
- }
- // ----------------------------------------------------------
- /**
- * Creates a new Floor object, with or without marbles.
- * This constructor is useful for writing software tests.
- * @param createBalls If true, the floor will be populated
- * with Marbles.
- */
- public Floor(boolean createMarbles)
- {
- super(12, 12, 60);
- if (createMarbles)
- {
- populate();
- }
- }
- //~ Methods ...............................................................
- // ----------------------------------------------------------
- /**
- * Add one marble for each y coordinate, at a random
- * x position.
- */
- private void populate()
- {
- int yValues = 12;
- for (int count = 0; count < yValues; count++)
- {
- Marble keith = new Marble();
- int x = Random.nextInt(12);
- int y = count;
- add(keith, x, y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement