Wrote an assignment jv-lambda-calc#305
Open
ASelivonchyk wants to merge 3 commits into
Open
Conversation
Wrote a calculator according to the conditions. Wrote test class with test cases.
MaliukDaria
suggested changes
Nov 10, 2021
| package core.basesyntax; | ||
|
|
||
| public interface Calculating { | ||
| double calculate(double num1, double num2, char operator); |
There was a problem hiding this comment.
Это плохая практика писать числа в названии переменных
| throw new ArithmeticException("Illegal division by 0"); | ||
| } | ||
| return num1 / num2; | ||
| default: throw new IllegalOperatorException("Use valid operator to calculate result"); |
There was a problem hiding this comment.
Suggested change
| default: throw new IllegalOperatorException("Use valid operator to calculate result"); | |
| default: throw new IllegalOperatorException("Invalid operator " + operator); |
Давай будем делать сообщения исключений более информативными
| class CalculatorTest { | ||
| private static Calculating calculator; | ||
| private static final double DELTA = 0.0001; | ||
| private double actual; |
There was a problem hiding this comment.
мне кажется нам не нужно выносить эту переменную на уровень класса
Comment on lines
+37
to
+39
| void calculate_additionPositiveAndNegativeOperands() { | ||
| actual = calculator.calculate(-4, 6, '+'); | ||
| assertEquals(2, actual); |
There was a problem hiding this comment.
Я б сюда еще добавила тест на первый позитивный и второй негативный операнды
Comment on lines
+44
to
+47
| actual = calculator.calculate(0, 5, '+'); | ||
| assertEquals(5, actual); | ||
| actual = calculator.calculate(10, 0, '+'); | ||
| assertEquals(10, actual); |
There was a problem hiding this comment.
тут можно добавить проверку на нулевые оба операнда
- added test of addition with 1 positive and 1 negative operands; - deleted double actual from class field; - changed message of IllegalOperatorException; - changed name of variable in interface;
- added test of addition with 1 positive and 1 negative operands; - deleted double actual from class field; - changed message of IllegalOperatorException; - changed name of variable in interface;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wrote a calculator according to the conditions.
Wrote test class with test cases.