package tcra.exercises.resolve_one_way_list_private;

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

public class ResolveOneWayList_PostAdvanceAssertion implements
      Assertion
{
   public ResolveOneWayList_PostAdvanceAssertion() {}
   
   @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(2);
      MathString<MathType> rem     = (MathString<MathType>)t.get(3);
      
      if(!(lb_prec.concat(lb_rem).equals(prec.concat(rem)))) return false;
      if(prec.length() != lb_prec.length()+1) 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(2);
      MathString<MathType> rem     = (MathString<MathType>)t.get(3);
      
      return ""+prec.toHTMLString()+" o "+rem.toHTMLString()+" = "+
             lb_prec.toHTMLString()+" o "+lb_rem.toHTMLString()+
             " and<br>|"+prec.toHTMLString()+"| = |"+
             lb_prec.toHTMLString()+"| + 1;";
   } // end toInstanceString(List<MathType>)

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