Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
lab5
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Isak.Graarud
lab5
Commits
691a92cc
Commit
691a92cc
authored
2 weeks ago
by
Isak.Graarud
Browse files
Options
Downloads
Patches
Plain Diff
compleated all tests
parent
b93f4a81
Branches
master
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/no/uib/inf101/calculator/Calculator.java
+13
-3
13 additions, 3 deletions
src/main/java/no/uib/inf101/calculator/Calculator.java
src/test/java/no/uib/inf101/calculator/CalculatorTest.java
+1
-1
1 addition, 1 deletion
src/test/java/no/uib/inf101/calculator/CalculatorTest.java
with
14 additions
and
4 deletions
src/main/java/no/uib/inf101/calculator/Calculator.java
+
13
−
3
View file @
691a92cc
...
...
@@ -8,7 +8,17 @@ import java.util.Map;
import
no.uib.inf101.calculator.expression.BinaryExpression
;
import
no.uib.inf101.calculator.expression.Expression
;
import
no.uib.inf101.calculator.expression.UnaryExpression
;
import
no.uib.inf101.calculator.operations.*
;
import
no.uib.inf101.calculator.operations.Addition
;
import
no.uib.inf101.calculator.operations.BinaryOperator
;
import
no.uib.inf101.calculator.operations.Exponent
;
import
no.uib.inf101.calculator.operations.Factorial
;
import
no.uib.inf101.calculator.operations.Ln
;
import
no.uib.inf101.calculator.operations.Log
;
import
no.uib.inf101.calculator.operations.Multiplication
;
import
no.uib.inf101.calculator.operations.Operator
;
import
no.uib.inf101.calculator.operations.Root
;
import
no.uib.inf101.calculator.operations.Subtraction
;
import
no.uib.inf101.calculator.operations.UnaryOperator
;
/**
* Represents a calculator that can evaluate mathematical expressions.
...
...
@@ -35,8 +45,8 @@ public class Calculator {
addOperator
(
new
Root
());
}
private
void
addOperator
(
String
operator
)
{
operators
.
put
(
operator
.
getSymbol
(),
string
);
private
void
addOperator
(
Operator
operator
)
{
operators
.
put
(
operator
.
getSymbol
(),
operator
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/test/java/no/uib/inf101/calculator/CalculatorTest.java
+
1
−
1
View file @
691a92cc
...
...
@@ -40,6 +40,6 @@ public class CalculatorTest {
assertEquals
(
"Factorial: \"The product of an integer and all the integers below it\""
,
calc
.
getOperatorDescription
(
"!"
));
assertEquals
(
"Logarithm: \"The power to which a given number must be raised to produce 10\""
,
calc
.
getOperatorDescription
(
"log"
));
assertEquals
(
"Logarithm: \"The power to which e must be raised to produce a given number\""
,
calc
.
getOperatorDescription
(
"ln"
));
assertEquals
(
"
√
"
,
calc
.
getOperatorDescription
(
"√"
));
assertEquals
(
"
Square root: \"A number which produces a specified quantity when multiplied by itself.\"
"
,
calc
.
getOperatorDescription
(
"√"
));
}
}
\ No newline at end of file
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