Commit 2394801

mo khan <mo@mokhan.ca>
2019-08-05 19:58:12
remove API that is not needed
1 parent 4b65f2f
Changed files (1)
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);
     }