Skip to content
Snippets Groups Projects
Commit b88da6ab authored by Christopher Bohn's avatar Christopher Bohn :thinking:
Browse files

Added JavaDoc to calculate() pure function

parent 92105fc5
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment