Skip to content

Wrote an assignment jv-lambda-calc#305

Open
ASelivonchyk wants to merge 3 commits into
mate-academy:masterfrom
ASelivonchyk:hw12-solution
Open

Wrote an assignment jv-lambda-calc#305
ASelivonchyk wants to merge 3 commits into
mate-academy:masterfrom
ASelivonchyk:hw12-solution

Conversation

@ASelivonchyk
Copy link
Copy Markdown

Wrote a calculator according to the conditions.
Wrote test class with test cases.

Wrote a calculator according to the conditions.
Wrote test class with test cases.
package core.basesyntax;

public interface Calculating {
double calculate(double num1, double num2, char operator);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это плохая практика писать числа в названии переменных

throw new ArithmeticException("Illegal division by 0");
}
return num1 / num2;
default: throw new IllegalOperatorException("Use valid operator to calculate result");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мне кажется нам не нужно выносить эту переменную на уровень класса

Comment on lines +37 to +39
void calculate_additionPositiveAndNegativeOperands() {
actual = calculator.calculate(-4, 6, '+');
assertEquals(2, actual);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я б сюда еще добавила тест на первый позитивный и второй негативный операнды

Comment on lines +44 to +47
actual = calculator.calculate(0, 5, '+');
assertEquals(5, actual);
actual = calculator.calculate(10, 0, '+');
assertEquals(10, actual);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут можно добавить проверку на нулевые оба операнда

- 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants