diff options
| author | mo khan <mo@mokhan.ca> | 2019-08-05 13:58:12 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2019-08-05 13:58:12 -0600 |
| commit | 239480183a0a385ef66f0882ed0d53c39b34bbe2 (patch) | |
| tree | ad821b939f40403892e3a402e8dab7a5bdfd4035 /src | |
| parent | 4b65f2f1b922d07c5ccd9a073b74baaef7769945 (diff) | |
remove API that is not needed
Diffstat (limited to 'src')
| -rw-r--r-- | src/Q9/MovingRobot.java | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/Q9/MovingRobot.java b/src/Q9/MovingRobot.java index 03d67c9..aa3ff6e 100644 --- a/src/Q9/MovingRobot.java +++ b/src/Q9/MovingRobot.java @@ -4,7 +4,6 @@ import java.util.*; public class MovingRobot extends Robot { private ArrayList<Integer> moves = new ArrayList<Integer>(); - private int nextMove; private Random rng; public MovingRobot(int x, int y) { @@ -12,10 +11,6 @@ public class MovingRobot extends Robot { this.rng = new Random(); } - public boolean validateNextMove() { - return validateNextMove(nextMove); - } - public boolean validateNextMove(int direction) { switch (direction) { case Robot.NORTH: @@ -55,9 +50,7 @@ public class MovingRobot extends Robot { public void move() { int direction = generateNextMove(); - // if (!validateNextMove(direction)) this.move(); - - // this.nextMove = direction; + while (!validateNextMove(direction)) direction = generateNextMove(); this.move(direction); } @@ -143,6 +136,8 @@ public class MovingRobot extends Robot { System.out.println( String.format("R1 (%d, %d), R2: (%d, %d)", r1.getX(), r1.getY(), r2.getX(), r2.getY())); System.out.println(Robot.printGrid(r1, r2)); + System.out.println(String.format("R1 Route: [%s]", r1.printMoves())); + System.out.println(String.format("R2 Route: [%s]", r2.printMoves())); sleep(1000); } |
