package tcra.exercises.q2_mystery_private;

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

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

   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> lb_self  = (MathString<MathType>)t.get(0);
      MathInteger          lb_index = (MathInteger)t.get(1);
      MathInteger          lb_count = (MathInteger)t.get(2);
      
      if(lb_index.getValue() < 0) return false;
      if(lb_index.getValue() > lb_self.length()) return false;
      if(lb_index.getValue() - lb_count.getValue() < 0) return false;
      
      return true;
   } // end check(List)
   
   public String toString()
   {
      return("index &gt;= 0 and<br>index &lt;<br>|#self| and<br>index - count &gt;= 0;");
   } // end toString()

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