package tcra.exercises.q2_mystery_private;

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

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

   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathInteger          lb_a1   = (MathInteger)t.get(1);
      MathInteger          lb_a2   = (MathInteger)t.get(2);
      MathInteger          lb_b1   = (MathInteger)t.get(3);
      MathInteger          lb_b2   = (MathInteger)t.get(4);
      
      if(lb_a1.getValue() < 0) return false;
      if(lb_a1.getValue() > lb_self.length()) return false;
      if(lb_a2.getValue() < lb_a1.getValue()) return false;
      if(lb_a2.getValue() > lb_self.length()) return false;
      if(lb_b1.getValue() < lb_a2.getValue()) return false;
      if(lb_b1.getValue() > lb_self.length()) return false;
      if(lb_b2.getValue() < lb_b1.getValue()) return false;
      if(lb_b2.getValue() >= lb_self.length()) return false;
      
      return true;
   } // end check(List)
   
   public String toString()
   {
	  return("a1 &gt;= 0 and<br>a1 &lt; |#self| and<br>a2 &gt; a1 and<br>a2"+
			 "&lt; |#self| and<br>b1 &gt; a2 and<br>b1 &lt; |#self| and<br>b2"+
			 "&gt; b1 and<br>b2 &lt;= |#self|;");
   } // end toString()

   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathInteger          lb_a1   = (MathInteger)t.get(1);
      MathInteger          lb_a2   = (MathInteger)t.get(2);
      MathInteger          lb_b1   = (MathInteger)t.get(3);
      MathInteger          lb_b2   = (MathInteger)t.get(4);
      
	  return(lb_a1.toHTMLString()+" &gt;= 0 and<br>"+
			 lb_a1.toHTMLString()+" &lt; |"+lb_self.toHTMLString()+"| and<br>"+
			 lb_a2.toHTMLString()+" &gt; "+lb_a1.toHTMLString()+" and<br>"+
			 lb_a2.toHTMLString()+" &lt; |"+lb_self.toHTMLString()+"| and<br>"+
			 lb_b1.toHTMLString()+" &gt; "+lb_a2.toHTMLString()+" and<br>"+
			 lb_b1.toHTMLString()+" &lt; |"+lb_self.toHTMLString()+"| and<br>"+
			 lb_b2.toHTMLString()+" &gt; "+lb_b1.toHTMLString()+" and<br>"+
			 lb_b2.toHTMLString()+" &lt;= |"+lb_self.toHTMLString()+"|;");
   } // end toInstanceString(List)
} // end class
