package tcra.exercises.resolve_bounded_queue_private;

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

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

   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathInteger          lb_swap = (MathInteger)t.get(1);
      MathString<MathType> self    = (MathString<MathType>)t.get(2);
      MathInteger          swap    = (MathInteger)t.get(3);
      
      MathString<MathType> rem =
                       (MathString<MathType>)lb_self.split(0).get(1);
      
      if(!lb_self.equals(rem.prepend(swap))) return false;
      if(!self.equals(rem.prepend(lb_swap))) return false;
      
      return true;
   } // end check(List)

   public String toString()
   {
      return("∃ Rem: String(Integer) ∋ #Q = &lt;I&gt; * Rem "+
             "<b>and</b> Q = &lt;#I&gt; * Rem;");
   } // end toString()
   
   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathInteger          lb_swap = (MathInteger)t.get(1);
      MathString<MathType> self    = (MathString<MathType>)t.get(2);
      MathInteger          swap    = (MathInteger)t.get(3);
      
      MathString<MathType> rem =
                       (MathString<MathType>)lb_self.split(0).get(1);
      
      return("∃ Rem: String(Integer) ∋ "+
             lb_self.toHTMLString() + " = &lt;"+
             swap.toHTMLString() + "&gt; * " + rem.toHTMLString() +
             " <b>and</b> " + self.toHTMLString() + " = &lt;" +
             lb_swap.toHTMLString() + "&gt; * " + rem.toHTMLString()+
             ";");
   } // end toInstanceString(List)
} // end class
