package tcra.exercises.resolve_stack_mystery_private;

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

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

   @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          mystery   = (MathInteger)t.get(3);
      
      MathString<MathType> rst = self.split(self.length()-2).get(0);
      
      if(!self.equals(rst.concat(mystery))) return false;
      if(!self.equals(lb_self)) return false;
      
      return true;
   } // end check(List)

   public String toString()
   {
      return("∃ Rst: Str(Integer) ∋ Rst * &lt;I&gt; = S;");
   } // end toString()
   
   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> self      = (MathString<MathType>)t.get(2);
      MathInteger          mystery   = (MathInteger)t.get(3);
      
      MathString<MathType> rst = self.split(self.length()-2).get(0);
      
      return("∃ Rst: Str(Integer) ∋ "+rst.toHTMLString()+
             " * &lt;"+mystery.toHTMLString()+"&gt; = "+
             self.toHTMLString()+";");
   } // end toInstanceString(List)
} // end class
