Skip to content

implement calculator#294

Open
Nazar-Hetun wants to merge 3 commits into
mate-academy:masterfrom
Nazar-Hetun:Calculator
Open

implement calculator#294
Nazar-Hetun wants to merge 3 commits into
mate-academy:masterfrom
Nazar-Hetun:Calculator

Conversation

@Nazar-Hetun
Copy link
Copy Markdown

No description provided.


public class Calculator {

public double calculate(double a, double b, char c) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use descriptive parameter and variable names.

Comment on lines +17 to +19
/*
Tests for additions.
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Don't use comments. Your code should be understandable without them

Comment on lines +23 to +24
double a = 23.4;
double b = 700.5;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

frequently used variables can be translated into constants.

Comment on lines +32 to +33
double a = -23.4;
double b = -700.5;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

frequently used variables can be translated into constants.

Comment on lines +19 to +21
if (a < 0 && b != (long) b) {
throw new RuntimeException("Error");
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is no need to throw Exception. We can raise any number to any power from a mathematical point of view.

void additionForMinAndMaxDoubleValues_isOk() {
double a = Double.MAX_VALUE;
double b = Double.MIN_VALUE;
double delta = 0.0001;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the delta variable must be declared constant. Check Common mistakes

}

@Test
void additionWithTwoPositiveOperands_isOk() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what method do we test?

@Test
void raisingZeroToPower() {
expected = ZERO_NUMBER;
actual = calculator.calculate(ZERO_NUMBER, POSITIVE_NUMBER_7, '^');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what about negative power?

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.

3 participants