package tcra.exercises.queue_reasoning_private;

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

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

   @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          length = (MathInteger)states.get(2);

      if(!self.equals(lb_self)) return false;
      if(self.length() != length.getValue()) return false;

      return true;
   } // end check(List)

   public String toString()
   {
      return "(length( ) = |#self|) and <br> (self = #self)";
   } // 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          length = (MathInteger)states.get(2);

      return ("(" +length+ " = |" +lb_self.toHTMLString()+
              "|) and <br> (" +self.toHTMLString()+
             " = " + lb_self.toHTMLString()+ ")");
   } // end toString(List)
} // end class
