diff --git a/src/main/java/edu/unl/cse/csce361/calculator/Calculator.java b/src/main/java/edu/unl/cse/csce361/calculator/Calculator.java index 05fa1bbfd394dc0e618e03e38c24e05dfd80aadf..ecc4a87250398dd6605bcec4824130d3e70bd644 100644 --- a/src/main/java/edu/unl/cse/csce361/calculator/Calculator.java +++ b/src/main/java/edu/unl/cse/csce361/calculator/Calculator.java @@ -66,7 +66,7 @@ public class Calculator { * <li>A {@link #OPERAND_TOO_LONG} will display an error message stating that the token was too long.</li> * </ul> * - * @param type the type of token received from the user + * @param type the type of token received from the user * @param token the token received from the user * @return the message to be displayed to the user, or {@code Null} if no message is to be displayed */ @@ -74,6 +74,23 @@ public class Calculator { return calculate(type, token, this.stack, this.stackPointer); } + /** + * <p>The core logic of the prefix calculator, using injected dependencies. The behavior is identical to + * {@link #calculate(int, char[])} except that the {@code stack} array and the {@code stackPointer} value are + * method parameters and not object fields.</p> + * + * <p>The {@code stackPointer} parameter indicates the top of the stack; its value is the number of items in the + * logical stack. Note that the {@code stack} parameter may include values that are not part of the stack. The + * logical stack are the values in {@code stack[0..stackPointer-1]}; the values in + * {@code stack[stackPointer..length-1]} are not part of the stack, and no guarantees are made about their + * values.</p> + * + * @param type the type of token received from the user + * @param token the token received from the user + * @param stack an array representing the calculator's stack + * @param stackPointer the value indicating the top of the stack + * @return the message to be displayed to the user, or {@code Null} if no message is to be displayed + */ String calculate(int type, char[] token, double[] stack, AtomicInteger stackPointer) { double number1; double number2; @@ -173,7 +190,8 @@ public class Calculator { /** * Extracts the next whitespace-delimited token from the user input and determines its type. * - * @param token a non-{@code Null} character array in which to place the token; any existing contents will be overwritten + * @param token a non-{@code Null} character array in which to place the token; any existing contents will be + * overwritten * @param limit the maximum allowable length of the token * @return the type of token * @throws IOException if there is a problem with processing the user's input (see