Skip to content

added solution#302

Open
YaroslavYarmoshyk wants to merge 2 commits into
mate-academy:masterfrom
YaroslavYarmoshyk:hw-10
Open

added solution#302
YaroslavYarmoshyk wants to merge 2 commits into
mate-academy:masterfrom
YaroslavYarmoshyk:hw-10

Conversation

@YaroslavYarmoshyk
Copy link
Copy Markdown

No description provided.

Comment on lines +20 to +23
} else {
result = a / b;
}
break;
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.

Suggested change
} else {
result = a / b;
}
break;
}
return result = a / b;

Comment on lines +25 to +26
result = Math.pow(a,b);
break;
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.

Suggested change
result = Math.pow(a,b);
break;
return Math.pow(a,b);

private double operand1;
private double operand2;
private double actual;
private char ch;
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.

Suggested change
private char ch;
private char operation;

Comment on lines +11 to +13
private double operand1;
private double operand2;
private double actual;
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.

так як ці змінні різні для кожного тест кейсу їх логічніше винести в окремі методи і не оголошувати на рівні класу

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

в принципі, ці змінні можна взагалі не створювати, а передавати відразу в метод цифри та char, чи не так?

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.

так, загаом можна одразу передавати, неймінг потрібен тількки якщо неочевидно чому те чи інше значення було передано (наприклад k як invalidOperation


@Test
void calculate_IllegalOperation_NotOk() {
if (ch != '+' && ch != '-' && ch != '*' && ch != '/' && ch != '^') {
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.

цей тест кейс краще зробити більш читаймим: оголосит невалідну операцію в методі, передати її в calculate і тоді очікувати ексепшн

operand2 = 3;
ch = '/';
actual = calculator.calculate(operand1,operand2,ch);
assertEquals(operand1 / operand2,actual);
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.

цей код не належить до випадку, коли ми ділимо на 0 краще його прибрати/перенести в інший тест кейс якщо в цьому є потреба


@Test
void calculate_IllegalOperation_NotOk() {
char operation = ')';
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.

Suggested change
char operation = ')';
char illegalOperation = ')';

double operand1 = 6;
double operand2 = 7;
char operation = '+';
double actual = calculator.calculate(operand1,operand2,operation);
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.

а тут так, можна прередавати значення одразу в calculate

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