package tcra.exercises.stack_reasoning_private;

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

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

   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> l)
   {
      MathString<MathType> lb_self = (MathString<MathType>)l.get(0);
      MathString<MathType> self    = (MathString<MathType>)l.get(1);
      MathType             top     = (MathType)l.get(2);

      if(!self.equals(lb_self)) return false;

      if(!self.compareElement(self.length()-1,top)) return false;

      return true;
   } // end check(List)

   public String toString()
   {
      return("there exists A: String of Object, b:Object<p>" +
             "(#self = A * &lt b &gt )<br>" +
             "(self = #self)<br>" +
             "(top( ) = b)");
   } // end toString()

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

      return("there exists A: String of Object, b:Object<br>" +
             "("+lb_self.toHTMLString()+"= A * &lt b &gt )<br>" +
             "("+self.toHTMLString()+" = "+l.get(0)+")<br>" +
             "("+top+" = b)");
   } // end toString()
} // end class
