import becker.robots.*;
import becker.io.*;

class MysteryRobot extends Robot
{
    int howManyThingsPerRow;
    
    // In addition to hte normal things we have to worry about, 
    // we also want to remember the number of things to pick up.
    MysteryRobot( City c, int ave, int st, Direction dir, int num, int numThingsPerRow)
    {
        super(c, st, ave, dir, num);
        this.howManyThingsPerRow = numThingsPerRow;
        System.out.println("There are " + this.howManyThingsPerRow + " things in each row!");
    }
    
    public void pickThingIfPresent()
    {
        if(this.canPickThing())
        {
            this.pickThing();
        }
    }	
    
    public void collectRow()
    {
        int howManyCollectedFromThisRow = 0;
        while(howManyCollectedFromThisRow < this.howManyThingsPerRow)
        {
            this.pickThingIfPresent();
            this.move();
            howManyCollectedFromThisRow = howManyCollectedFromThisRow + 1;
        }
    }
}

public class ICE_09_Demo_1 extends Object
{
    public static void main(String[] args)
    { 
        City ForgetsVille = new City();
        // We want the robot to remember that a row of things is 3 intersections long
        // thus the new, additional argument (3) at the end of the normal ones.
        MysteryRobot mary = new MysteryRobot(ForgetsVille, 4, 4, Direction.WEST, 0, 3);
        
        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();
        mary.collectRow();
        mary.turnLeft();
        mary.move();
        mary.turnLeft();
        mary.move();
        mary.collectRow();
    }
}

