001/* This source code is released under the new BSD license, a copy of the 002 * license is in the distribution directory. */ 003 004package mazerob.pc; 005 006import java.io.IOException; 007import mazerob.pc.Robot; 008 009/** 010 * Program that solves a maze. 011 */ 012class MazeSolver { 013 /** 014 * Method that executes the {@link mazerob.pc.Robot} instance 015 * commands for solving the maze. 016 * 017 * @param r {@link mazerob.pc.Robot} instance. 018 */ 019 public static void solveMaze(Robot r) throws IOException { 020 String continueMsg = "Press enter to continue"; 021 String exitMsg = "Press enter to exit"; 022 023 // THIS IS A DEMO! 024 r.translateForward(); 025 System.out.print(continueMsg); System.in.read(); 026 r.translateBackward(); 027 System.out.print(continueMsg); System.in.read(); 028 r.rotateRight(); 029 System.out.print(continueMsg); System.in.read(); 030 r.rotateLeft(); 031 System.out.print(continueMsg); System.in.read(); 032 r.scan(); 033 System.out.print(continueMsg); System.in.read(); 034 035 r.translate(50.0); 036 System.out.print(continueMsg); System.in.read(); 037 r.translate(50.0); 038 System.out.print(continueMsg); System.in.read(); 039 r.translate(-50.0); 040 System.out.print(continueMsg); System.in.read(); 041 r.rotate(180.0); 042 System.out.print(continueMsg); System.in.read(); 043 r.rotate(-45.0); 044 System.out.print(continueMsg); System.in.read(); 045 r.rotate(-45.0); 046 047 System.out.print(exitMsg); System.in.read(); 048 r.end(); 049 } 050}