Skip to content
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

Open
wants to merge 3 commits into
base: Hyojung-lee
Choose a base branch
from
Open

Conversation

KimGyeong
Copy link

No description provided.

Copy link
Author

@KimGyeong KimGyeong left a comment

Choose a reason for hiding this comment

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

@Hyojung-Lee 코멘트 확인해주세요.

Comment on lines +2 to +8
public static void main(String[] args){
calculate();
}
public static void calculate(){
StringCalculator stringCalculator = new StringCalculator();
Output.printOutput(stringCalculator.calculateStr(Input.splitInput()));
}
Copy link
Author

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){
Copy link
Author

Choose a reason for hiding this comment

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

메소드 네임에는 타입이 들어가는 것을 추천드리지 않아요. 간단하게 calculate로 바꿔도 괜찮을 것 같습니다.

Comment on lines +39 to +41
} catch(ArithmeticException e){
System.out.println("0 으로 나눌수 없음 : " + num1 + "/" + num2);
}
Copy link
Author

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){
Copy link
Author

Choose a reason for hiding this comment

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

한 클래스 내에서만 사용하는 메소드는 접근제어자를 private으로 변경해주세요.
또한 연산 입력의 오류의 케이스가 더 있을 것 같은데 한번 생각해보면 좋을 것 같아요.

Comment on lines +13 to +36
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){
Copy link
Author

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();
Copy link
Author

Choose a reason for hiding this comment

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

어떤 케이스에 대한 예외인가요?

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.

1 participant