-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(이주연) StringCalculator 리뷰 요청드립니다. #29
base: jooyeon/main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
객체 지향 설계 원칙에 대해서 공부해보고 코드를 작성해보세요.
switch (operator) { | ||
case "+": | ||
currentResult += number; | ||
break; | ||
case "-": | ||
currentResult -= number; | ||
break; | ||
case "*": | ||
currentResult *= number; | ||
break; | ||
case "/": | ||
if (number == 0) { | ||
throw new ArithmeticException("0으로 나눌 수 없습니다."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum을 사용해서 switch문을 사용하지 않는 방향으로 코드를 작성해봅시다
currentResult /= number; | ||
break; | ||
default: | ||
System.out.println("지원하지 않는 연산자입니다: " + operator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calculator 클래스의 책임은 무엇인가요.
한 클래스에 여러 개의 책임이 있는 것 같습니다.
SCP에 대해서 공부해보고 코드를 작성해주세요
public boolean isValid(String expression) { | ||
String[] tokens = expression.split(" "); | ||
|
||
if (tokens.length % 2 == 0) { | ||
return false; | ||
} | ||
|
||
if (!isNumeric(tokens[0])) { | ||
return false; | ||
} | ||
|
||
for (int i = 1; i < tokens.length; i += 2) { | ||
if (!isOperator(tokens[i]) || !isNumeric(tokens[i + 1])) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
한 메소드가 많은 역할을 해주는 것 같습니다.
각각의 if문을 여러 메소드로 나누어보세요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main 클래스에 너무 많은 책임이 있습니다.
SCP에 대해서 공부 해보고 코드를 작성해주세요
- 콘솔에 프린트해주는 것도 하나의 책임으로 봅니다
리뷰 요청드립니다