package tcra.exercises.resolve_bounded_stack_private;

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

public class ResolveBoundedStack_PostRem_CapacityAssertion implements
      Assertion
{
   public ResolveBoundedStack_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(new MathInteger(
                          ResolveBoundedStackExercise.getMaxDepth() -
                          lb_self.length())))
         return false;
      
      return true;
   }

   public String toString()
   {
      return("Rem_Capacity = (Max_Depth - |S|);");
   }
   
   @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 + " = (" +
             ResolveBoundedStackExercise.getMaxDepth() +
             " - |" + lb_self.toHTMLString() + "|);");
   }

}
