From 239480183a0a385ef66f0882ed0d53c39b34bbe2 Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 5 Aug 2019 13:58:12 -0600 Subject: remove API that is not needed --- src/Q9/MovingRobot.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src') 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 moves = new ArrayList(); - 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); } -- cgit v1.2.3