package tcra.exercises.resolve_appending_capability_private;

import java.util.List;
import tcra.math.*;
import tcra.exercises.ResolveBoundedQueueExercise;

public class ResolveAppendingCapability_PreAppend_QAssertion
      implements Assertion
{
   public ResolveAppendingCapability_PreAppend_QAssertion() {}

   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> lb_self   = (MathString<MathType>)t.get(0);
      MathString<MathType> lb_append = (MathString<MathType>)t.get(1);
      int ml = ResolveBoundedQueueExercise.getMaxLength();

      return((lb_append.length() + lb_self.length()) <= ml);
   } // end check(List)
   
   public String toString()
   {
      return("|P| + |Q| ≤ Max_Length;");
   } // end toString()

   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> lb_self   = (MathString<MathType>)t.get(0);
      MathString<MathType> lb_append = (MathString<MathType>)t.get(1);
      int ml = ResolveBoundedQueueExercise.getMaxLength();
      
      return("|"+lb_append.toHTMLString()+"| + |"+
             lb_self.toHTMLString()+" ≤ "+ml+";");
   } // end toInstanceString(List)
} // end class
