package tcra.exercises.stack_reasoning_private;

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

public class StackPostPushAssertion implements Assertion
{
   /**
    * Default Constructor
    */
   public StackPostPushAssertion() {}

   /* This list must agree between what the GUI is going to send
    * and what the implementation of the exercise wants :(
    *
    * ? Just agree on: #self, #arg1, #arg2,...,self, arg1, arg2,...?
    *
    */
   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> argVals)
   {
      MathString<MathInteger> lb_self =
         (MathString<MathInteger>)argVals.get(0);
      MathInteger             lb_arg  = (MathInteger)argVals.get(1);
      MathString<MathInteger> self    =
         (MathString<MathInteger>)argVals.get(2);
      MathInteger             arg     = (MathInteger)argVals.get(3);

      return (lb_arg.equals(arg) &&
              self.equals(lb_self.concat(lb_arg)));
   } // end check(List<Object>)

   public String toString()
   {
      return "\t[x == #x]<br>and<br>\t[self == #self * #x]";
   } // end toString()

   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> argVals)
   {
      MathString<MathType> lb_self =
                                 (MathString<MathType>)argVals.get(0);
      MathType             lb_arg  = (MathType)argVals.get(1);
      MathString<MathType> self    =
                                 (MathString<MathType>)argVals.get(2);
      MathType             arg     = (MathType)argVals.get(3);

      return "(" + arg + " == " + lb_arg + ")<br>" +
             "and<br>\t(" + self.toHTMLString() + " == " +
             lb_self.toHTMLString() + " * &lt " + lb_arg + " &gt)";
   } // end toString(List<Object>)
}
