package tcra.exercises.resolve_one_way_list_private;

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

public class ResolveOneWayList_PostRemoveAssertion implements
      Assertion
{
   public ResolveOneWayList_PostRemoveAssertion() {}
   
   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> lb_prec = (MathString<MathType>)t.get(0);
      MathString<MathType> lb_rem  = (MathString<MathType>)t.get(1);

      MathString<MathType> prec    = (MathString<MathType>)t.get(3);
      MathString<MathType> rem     = (MathString<MathType>)t.get(4);
      MathInteger          ent     = (MathInteger)t.get(5);
      
      if(!prec.equals(lb_prec)) return false;
      if(!lb_rem.equals(rem.prepend(ent))) return false;
      
      return true;
   } // end check(List<MathType>)

   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> lb_prec = (MathString<MathType>)t.get(0);
      MathString<MathType> lb_rem  = (MathString<MathType>)t.get(1);

      MathString<MathType> prec    = (MathString<MathType>)t.get(3);
      MathString<MathType> rem     = (MathString<MathType>)t.get(4);
      MathInteger          ent     = (MathInteger)t.get(5);
    
      return ""+prec.toHTMLString()+" = "+
             lb_prec.toHTMLString()+" and<br>"+
             lb_rem.toHTMLString()+" = &lt;"+
             ent.toHTMLString()+"&gt; o "+rem.toHTMLString();
   } // end toInstanceString(List<MathType>)

   public String toString()
   {
      return "P.Prec = #P.Prec and<br>#P.Rem = &lt; Entry_Removed &gt;"+
             " o P.Rem";
   } // end toString()
} // end class
