package tcra.exercises.resolve_bounded_queue_private;

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

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

   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathString<MathType> self    = (MathString<MathType>)t.get(1);
      MathInteger rem_capacity     = (MathInteger)t.get(2);
      
      if(!self.equals(lb_self)) return false;
      if(!rem_capacity.equals(
                         ResolveBoundedQueueExercise.getMaxLength() -
                         lb_self.length()))
         return false;
      
      return true;
   } // end check(List)

   public String toString()
   {
      return("Rem_Capacity = (Max_Length - |Q|;");
   } // end toString()
   
   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathInteger rem_capacity     = (MathInteger)t.get(2);
      
      return(rem_capacity.toHTMLString() + " = (" +
             ResolveBoundedQueueExercise.getMaxLength() +
             "- |" + lb_self.toHTMLString() + "|;");
   } // end toInstanceString(List)
} // end class
