
/**
 * Solution to problem 2-5 in the Bergin book.  Get out of bed,
 * fetch the paper, and go back to bed
 * 
 * @author Russell C. Bjork 
 * @version January 6, 2006
 */
import kareltherobot.*;

public class Problem2_5 implements Runnable
{
	/** Main method - set up the world and start the program
	 */
    public static void main(String [] args)
    { 
      	World.readWorld("Problem2_5.world");
      	World.setVisible(true);
      	World.setupThread(new Problem2_5());
      	World.setTrace(false);
      	World.showSpeedControl(true);
    }
    
    /** Method that describes the task to be performed.
     */  
    public void run()
    {
        // Create a new robot at 3rd St and 4th Ave, facing West, with no beepers
 		
        Robot karel = new Robot(3, 4, Directions.West, 0);        

		// Go to door
				
        karel.turnLeft(); karel.turnLeft(); karel.turnLeft();
        karel.move();
        karel.move();
        
        // Go outside
        
        karel.turnLeft();
        karel.move();
        karel.move();
        
        // Go to beeper and pick it up
        
        karel.turnLeft();
        karel.move();
        karel.move();
        karel.turnLeft();
        karel.move();
        karel.pickBeeper();
        
        // Go back to door
        
        karel.turnLeft();
        karel.turnLeft();
        karel.move();
        karel.turnLeft(); karel.turnLeft(); karel.turnLeft();
        karel.move();
        karel.move();
        
        // Go back in the house
         
        karel.turnLeft(); karel.turnLeft(); karel.turnLeft();
        karel.move();
        karel.move();
        
        // Go back to bed
        
        karel.turnLeft(); karel.turnLeft(); karel.turnLeft();
        karel.move();
        karel.move();
        karel.turnLeft(); karel.turnLeft(); karel.turnLeft();
        karel.turnOff();
	}
}