package uk.co.patrickhaston.mars;

public class MarsGoals extends MarsArray 
{
  // Contents
  
  public MarsGoals()
  {
    this.CollectionName = "[Goals]";
  }
  
  public void readData(String line)
  {
    int idx = readIndex(line);
    if (idx>0)
    {
      MarsGoal g = new MarsGoal(line);

      this.setElementAt(g, idx);
    }
  }

  public MarsGoal nextStep(int role, int step)
  {
    MarsGoal first = null;
    for (int i=1; i<this.size(); i++)
    {
      MarsGoal g = new MarsGoal( (MarsGoal) this.elementAt(i));
      if ((g.role == role) && (g.step == 1)) first = new MarsGoal(g);
      if ((g.role == role) && (g.step == step + 1)) return g;
    }
    return first;
  }
}
