/* * CalculatorModel.java * * Created on December 5, 2002, 2:11 AM */ package Calculator; import CollabUtils.*; import java.util.GregorianCalendar; import java.util.Iterator; import java.util.List; /** See the documentation for ICalculatorModel and IApplicationIdentification. */ public class CalculatorModel implements ICalculatorModel, IApplicationIdentification { /** Creates a new instance of CalculatorModel */ public CalculatorModel() { } public String getApplicationAuthor() { } /** return a string (as long as desired) identifying the authors of the program. */ public String getApplicationAuthorDetails() { } /** return the date of creation or update */ public GregorianCalendar getApplicationDate() { } /** return a (short) description of the application. */ public String getApplicationDescription() { } /** return a string (as long as desired) describing the application */ public String getApplicationDescriptionDetails() { } /** return a string (as long as desired) giving any details of * usage or applicability which the author wishes to convey to * a user or a client. */ public String getUsageInformation() { } /** Answer, what is the current expression? * @return a string with all the tokens of the original expression, in the * usual left-to-right infix notation. Note that the current expression might * have been invalid, but this method will still return it. * @throws RuntimeException is no expression has yet been set. */ public String currentExpression() { } /** Set the number base which will be assumed for integer tokens in all subsequent new * expressions. * * Models are free to accept or reject any base except 10, which must always * be accepted. * @return true if the model accepts the change to the desired number base. * @return false if the model does not accept the change. * public boolean setNumberBase(int radix); * * /** Answer, what is the value of the current expression? * @return the (correct) value of the current expression, if there is one, * as a string with no leading * or trailing whitespace and no leading zeros. If the current expression * is invalid, return an empty string (not a null reference). * @throws RuntimeException is no expression has yet been set. */ public String currentValue() { } /** Answer, what is the value of the latest expression? * The current expression is the last valid expression received. * Pre: a valid expressed is present. * Post: None of the tokens have been modified. * @return the integer value of the last valid expression. * @throws RuntimeException If no valid expression has yet been received, or the latest expression * was invalid, the method should throw a runtime error, with a message * (in the exception) describing the reason for the exception. */ public int evaluateExpression() { } /** Set the next expression to be evaluated. * The previous expression is forgotten. * Note: it is NOT an error to set a new expression when the old one's value * has never been called for. * * @param expressionTokens An iterator to a list of the tokens in the expression * in their original, left-to-right, infix order. Each token is a string. * For example, the expression 1 + (300 - 17) would correspond to a token * list of: "1" "+" "(" "300" "-" "17" ")". * Pre: The token list is non-empty * Post: If the token list was valid (in all respects relative to the model's * ability to evaluate it), then the expression has been saved within the model. * @return -1 if the token list was valid. If not valid, the return value is * a list position where an error was detected. By convention, this should * be the position of the first error, but that need not be guaranteed. */ public int setExpression(Iterator expressionTokens) { } /** Signal that the model will not be called upon again. */ public void terminate() { } }