Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
calculator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CSCE 361
starter code
calculator
Commits
b88da6ab
Commit
b88da6ab
authored
5 years ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Added JavaDoc to calculate() pure function
parent
92105fc5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/edu/unl/cse/csce361/calculator/Calculator.java
+20
-2
20 additions, 2 deletions
src/main/java/edu/unl/cse/csce361/calculator/Calculator.java
with
20 additions
and
2 deletions
src/main/java/edu/unl/cse/csce361/calculator/Calculator.java
+
20
−
2
View file @
b88da6ab
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment