package tcra.exercises.queue_reasoning_private;

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

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

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

      if(self.length() != lb_self.length()-1) return false;
      if(!lb_self.equals(self.prepend(dequeue))) return false;

      return true;
   } // end check(List)

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

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

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