package tcra.exercises.resolve_one_way_list_private;

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

public class ResolveOneWayList_PostSwapRemaindersAssertion implements
      Assertion
{
   public ResolveOneWayList_PostSwapRemaindersAssertion() {}
   
   @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> lb_other_prec = (MathString<MathType>)t.get(2);
      MathString<MathType> lb_other_rem  = (MathString<MathType>)t.get(3);
      MathString<MathType> prec          = (MathString<MathType>)t.get(4);
      MathString<MathType> rem           = (MathString<MathType>)t.get(5);
      MathString<MathType> other_prec    = (MathString<MathType>)t.get(6);
      MathString<MathType> other_rem     = (MathString<MathType>)t.get(7);
      
      if(!prec.equals(lb_prec))             return false;
      if(!other_prec.equals(lb_other_prec)) return false;
      if(!rem.equals(lb_other_rem))         return false;
      if(!other_rem.equals(lb_rem))         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> lb_other_prec = (MathString<MathType>)t.get(2);
      MathString<MathType> lb_other_rem  = (MathString<MathType>)t.get(3);
      MathString<MathType> prec          = (MathString<MathType>)t.get(4);
      MathString<MathType> rem           = (MathString<MathType>)t.get(5);
      MathString<MathType> other_prec    = (MathString<MathType>)t.get(6);
      MathString<MathType> other_rem     = (MathString<MathType>)t.get(7);
      
      return ""+prec.toHTMLString()+" = "+lb_prec.toHTMLString()+" and "+
             other_prec.toHTMLString()+" = "+
             lb_other_prec.toHTMLString()+" and<br>"+
             rem.toHTMLString()+" = "+lb_other_rem.toHTMLString()+" and "+
             other_rem.toHTMLString()+" = "+lb_rem.toHTMLString()+";";
   } // end toInstanceString(List<MathType>)

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