package com.horstmann.labrat;

import java.util.ArrayList;
import org.apache.tools.ant.*;

public class Check extends Task implements TaskContainer {
   public void addTask(Task task) {
      tasks.add(task);
   }

   public void execute() throws BuildException 
   {
      exception = null;
      try
      {
         for (Task task : tasks)
            task.perform();
      }
      catch (BuildException ex)
      {
         exception = ex;
         if (failonerror) throw ex;
         getWrapper().getAttributeMap().put("ex", ex);
      }
   }

   public void setScore(int score) { this.score = score; }
   public void setPenalty(int penalty) { this.penalty = penalty; }
   public void setFailonerror(boolean failonerror) { this.failonerror = failonerror; }

   private ArrayList<Task> tasks = new ArrayList<Task>();
   private int score;
   private int penalty;
   private boolean failonerror;
   private BuildException exception;
}
