import java.util.Scanner; /** * Write a description of class RobotTester here. * * @author Scott Russell * @version 11/9/2007 */ public class RobotTester { /** * An example of a method - replace this comment with your own * * @param y a sample parameter for a method * @return the sum of x and y */ public static void main(String[] args) { // create maze and robot Maze maze = new Maze(); // make sure to place robot at a maze location that isn't a wall! RandomRobot rob = new RandomRobot(startX,startY); Scanner input = new Scanner(System.in); char command = ' '; //continue to get command until decide to quit or edge of maze reached do { // Describe robot's position in the maze System.out.println(); System.out.println(maze.showIn(rob.getX(), rob.getY())); System.out.print("\nPress " + QUIT + " to quit, any other key to continue: "); command = input.next().toUpperCase().charAt(0); if (command != QUIT) rob.move(maze); // until decide to quit or reach a maze edge, presumably an entrance/exit } while (command != QUIT && rob.getX() != 0 && rob.getY() != 0 && rob.getX() != maze.getXWidth() -1 && rob.getY() != maze.getYWidth() -1); if (command != QUIT) { // show final position exiting maze System.out.println(maze.showIn(rob.getX(), rob.getY())); System.out.println("Congratulations Robot, you escaped!"); } } public static final int startX = 7; public static final int startY = 6; public static final char QUIT = 'Q'; }