package tcra.exercises.resolve_stack_mystery_private;

import java.util.Vector;
import tcra.math.*;
import tcra.programmatic.*;
import tcra.exercises.general_assertions.*;

public class ResolveStackMystery_Mystery1_3 extends MethodContract
{
   protected MathString<MathType> lb_self;
   protected MathString<MathType> self;

   public ResolveStackMystery_Mystery1_3()
   {
      super("Mystery1_3");
      precondition  = new TrueAssertion();
      postcondition =
                    new ResolveStackMystery_PostMystery1_3Assertion();
      returnType    = new VoidType();
   } // end ctor

   public boolean check(String[] l) throws MathFormatException
   {
      MathStringParser msp = new MathStringParser(
            new MathIntegerParser());
      lb_self = msp.parse(new StringBuilder(l[0]));
      self    = msp.parse(new StringBuilder(l[1]));
      
      if(lb_self == null || self == null)
         throw new MathFormatException(
                   "One or more unparsable objects.");

      Vector<MathType> state = new Vector<MathType>();
      state.add(lb_self);
      state.add(self);

      return(precondition.check(state) &&
             postcondition.check(state));
   } // end check(String[])

   public String toString()
   {
      return("<html>Operation Mystery1_3(updates S: Stack);<br>"+
             "ensures " + postcondition);
   } // end toString()
   
   public String toInstanceString()
   {
      Vector<MathType> state = new Vector<MathType>();
      state.add(lb_self);
      state.add(self);
      
      return("<html>Operation Mystery1_3(updates S: Stack);<br>"+
            "ensures " + postcondition.toInstanceString(state));
   } // end toInstanceString()
} // end class
