-
Notifications
You must be signed in to change notification settings - Fork 257
full test coverage #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
full test coverage #289
Changes from 2 commits
d4634a0
2e94529
cca4ca4
91d6446
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package core.basesyntax; | ||
|
|
||
| public class Calculator { | ||
| private static final char ADDITION_OPERATOR = '+'; | ||
| private static final char SUBTRACTION_OPERATOR = '-'; | ||
| private static final char MULTIPLICATION_OPERATOR = '*'; | ||
| private static final char DIVISION_OPERATOR = '/'; | ||
| private static final char RAISING_TO_POWER_OPERATOR = '^'; | ||
|
|
||
| public double calculate(double firstValue, double secondValue, char operation) { | ||
| switch (operation) { | ||
| case ADDITION_OPERATOR: | ||
| return firstValue + secondValue; | ||
| case SUBTRACTION_OPERATOR: | ||
| return firstValue - secondValue; | ||
| case MULTIPLICATION_OPERATOR: | ||
| return firstValue * secondValue; | ||
| case DIVISION_OPERATOR: | ||
| if (secondValue == 0) { | ||
| throw new ArithmeticException("can`t divide on 0"); | ||
| } | ||
| return firstValue / secondValue; | ||
| case RAISING_TO_POWER_OPERATOR: | ||
| if (secondValue == Double.MIN_VALUE) { | ||
| throw new IllegalValueException("can`t resolve operation"); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need this Exception? Raising with MIN_VALUE is corectly work, as with ZERO.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it return NuN not 0. Look at this screen -> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return Math.pow(firstValue, secondValue); | ||
| default: | ||
| throw new IllegalOperatorException("can't recognise operator, try again"); | ||
| } | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package core.basesyntax; | ||
|
|
||
| public class IllegalOperatorException extends RuntimeException { | ||
| public IllegalOperatorException(String message) { | ||
| super(message); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package core.basesyntax; | ||
|
|
||
| public class IllegalValueException extends RuntimeException { | ||
| public IllegalValueException(String message) { | ||
| super(message); | ||
| } | ||
| } |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RC means Release Candidate, it could be not stable, try to avoid using RC versions