import becker.robots.*;
import becker.io.*;

class MysteryRobot extends Robot
{
    MysteryRobot( City c, int st, int ave, Direction dir, int num)
    {
        	super(c, st, ave, dir, num);
			System.out.println("MysteryRobot was just created!");
    }
    
    public void pickThingIfPresent()
    {
        if(this.canPickThing())
        {
            this.pickThing();
        }
    }	
    
    public void collectRow(int howMany)
    {
        int howManyCollectedFromThisRow = 0;
        while(howManyCollectedFromThisRow < howMany)
        {
            this.pickThingIfPresent();
            this.move();
            howManyCollectedFromThisRow = howManyCollectedFromThisRow + 1;
        }
    }
}

public class ICE_09_Demo_2 extends Object
{
    public static void main(String[] args)
    { 
        City ForgetsVille = new City();
        MysteryRobot mary = new MysteryRobot(ForgetsVille, 4, 4, Direction.WEST, 0);
		  Robot plainOldBot = new Robot(ForgetsVille, 2, 4, Direction.WEST, 0);
        
        new Thing(ForgetsVille, 4, 1);
        new Thing(ForgetsVille, 4, 2);
        new Thing(ForgetsVille, 4, 3);
        new Thing(ForgetsVille, 5, 1);
        new Thing(ForgetsVille, 5, 2);
        new Thing(ForgetsVille, 5, 3);

        
        mary.move(); // move into the field
		  
        mary.collectRow( 3 ); // collect the Things from this row
		  
        mary.turnLeft(); // move down to the next row
        mary.move();
        mary.turnLeft();
		  
        mary.move(); // move into the field
		  
        mary.collectRow( 3 ); // collect the last row
    }
}

