implement calculator#294
Conversation
|
|
||
| public class Calculator { | ||
|
|
||
| public double calculate(double a, double b, char c) { |
There was a problem hiding this comment.
use descriptive parameter and variable names.
| /* | ||
| Tests for additions. | ||
| */ |
There was a problem hiding this comment.
Don't use comments. Your code should be understandable without them
| double a = 23.4; | ||
| double b = 700.5; |
There was a problem hiding this comment.
frequently used variables can be translated into constants.
| double a = -23.4; | ||
| double b = -700.5; |
There was a problem hiding this comment.
frequently used variables can be translated into constants.
| if (a < 0 && b != (long) b) { | ||
| throw new RuntimeException("Error"); | ||
| } |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
the delta variable must be declared constant. Check Common mistakes
| } | ||
|
|
||
| @Test | ||
| void additionWithTwoPositiveOperands_isOk() { |
There was a problem hiding this comment.
what method do we test?
| @Test | ||
| void raisingZeroToPower() { | ||
| expected = ZERO_NUMBER; | ||
| actual = calculator.calculate(ZERO_NUMBER, POSITIVE_NUMBER_7, '^'); |
There was a problem hiding this comment.
what about negative power?
No description provided.