package tcra.exercises.resolve_bounded_stack_private;

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

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

   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathString<MathType> self    = (MathString<MathType>)t.get(2);
      MathInteger          pop     = (MathInteger)t.get(3);
      
      if(lb_self.equals(self.prepend(pop))) return true;
      
      return false;
   }

   public String toString()
   {
      return("<html>#S = &lt;I&gt; * S;");
   }
   
   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathString<MathType> self    = (MathString<MathType>)t.get(2);
      MathInteger          pop     = (MathInteger)t.get(3);
      
      return(lb_self.toHTMLString()+ " = &lt;" + pop.toHTMLString()
             + "&gt; * " + self.toHTMLString() + ";");
   }

}
