-
Notifications
You must be signed in to change notification settings - Fork 3
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
PR for code review #6
base: Hyojung-lee
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.
@Hyojung-Lee 코멘트 확인해주세요.
public static void main(String[] args){ | ||
calculate(); | ||
} | ||
public static void calculate(){ | ||
StringCalculator stringCalculator = new StringCalculator(); | ||
Output.printOutput(stringCalculator.calculateStr(Input.splitInput())); | ||
} |
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.
굳이 분리하지 않아도 괜찮지 않을까요?
|
||
public class StringCalculator { | ||
|
||
public int calculateStr(String[] inputSplit){ |
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.
메소드 네임에는 타입이 들어가는 것을 추천드리지 않아요. 간단하게 calculate
로 바꿔도 괜찮을 것 같습니다.
} catch(ArithmeticException e){ | ||
System.out.println("0 으로 나눌수 없음 : " + num1 + "/" + num2); | ||
} |
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.
👍
return splitString; | ||
} | ||
|
||
public static void checkInput(String[] splitInput){ |
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.
한 클래스 내에서만 사용하는 메소드는 접근제어자를 private
으로 변경해주세요.
또한 연산 입력의 오류의 케이스가 더 있을 것 같은데 한번 생각해보면 좋을 것 같아요.
public int calculate(int firstFactor, char operator, int secondFactor) { | ||
if (operator == '+') | ||
return add(firstFactor,secondFactor); | ||
if (operator == '-') | ||
return subtract(firstFactor,secondFactor); | ||
if (operator == '*') | ||
return multiply(firstFactor,secondFactor); | ||
if (operator == '/') | ||
return divide(firstFactor,secondFactor); | ||
|
||
throw new RuntimeException("올바르지 않은 연산자"); | ||
} | ||
|
||
|
||
public int add(int num1, int num2){ | ||
return num1 + num2; | ||
} | ||
public int subtract(int num1, int num2){ | ||
return num1 - num2; | ||
} | ||
public int multiply(int num1, int num2){ | ||
return num1 * num2; | ||
} | ||
public int divide(int num1, int num2){ |
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.
접근제어자 변경해주세요
} catch(ArithmeticException e){ | ||
System.out.println("0 으로 나눌수 없음 : " + num1 + "/" + num2); | ||
} | ||
throw new RuntimeException(); |
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.
어떤 케이스에 대한 예외인가요?
No description provided.