import becker.robots.*;

class RobotThatKeepsGoing extends Robot
{
    RobotThatKeepsGoing(City c, int st, int ave, Direction dir, int num)
    {
        super(c, st, ave, dir, num);
    }

    /**
     * Moves the robot forward while no walls are ahead
    */
    public void keepGoing()
    {
        // If there's no wall in front of the robot, then frontIsClear
        // will say "true".
        while(this.frontIsClear() )
			{
            this.putThing(); // notice how many things the robot starts with?
            this.move();
        }
    }
}

public class ICE_05_Trace extends Object
{
    public static void main(String[] args)
    {
        City wallville = new City();
        RobotThatKeepsGoing ian = new RobotThatKeepsGoing(wallville, 4, 0, Direction.EAST, 1000);

		  /* build walls*/
        new Wall(wallville, 4, 2, Direction.EAST);
        new Wall(wallville, 1, 2, Direction.SOUTH);

		  // first, the robot moves TO one of the walls, and stops
        ian.keepGoing();
        
        // next, the robot moves to the other wall, and stops
        // ian.turnLeft();
        ian.turnLeft();

        while(ian.frontIsClear() )
			{
            ian.putThing(); // notice how many things the robot starts with?
            ian.move();
        }
        
        // At no point should the robot break
    }
}
