-
Notifications
You must be signed in to change notification settings - Fork 340
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
[자판기] 유재건 미션 제출합니다. #167
base: main
Are you sure you want to change the base?
[자판기] 유재건 미션 제출합니다. #167
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.
프로그래밍 요구사항에 맞춰서 다시 리팩토링해보시면 좋을것같아요!
public int getAmount(){ | ||
return this.amount; | ||
} | ||
public static Coin of(int amount){ |
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.
코드 포맷팅 해주시면 좋을것같아요!
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 void changeValidation(int change) { | ||
if (change % coins.stream() |
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 구문에 stream이 같이 들어가니 읽기가 조금 어렵네요 ㅠㅠ
coins.stream()... 에 대한 결과값을 변수로 한번 분리하는게 좋아보여요
return initCoin; | ||
} | ||
|
||
private void coinMaker(int change) { |
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.
해당 네이밍은 뭔가 클래스명처럼 보이네요..
createCoin과 같이 메소드 이름은 동사 혹은 동사구가 적합합니다.
참고 내용
} | ||
|
||
|
||
public String startChangePrint() { |
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.
toString 혹은 printChange같은 네이밍은 어떨까요
changeAmount += tempCoin.getAmount(); | ||
} | ||
} | ||
return; |
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을 작성하신 이유가 있을까요?
return; | ||
} | ||
|
||
public String leftChangePrint(){ |
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.
printLeftChange라는 네이밍은 어떨까요
StringBuilder print = new StringBuilder(); | ||
print.append(CHANGE_MESSAGE.getMessage()); | ||
for (Coin tempCoin : leftCoins.keySet()) { | ||
if(leftCoins.get(tempCoin) >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.
if(leftCoins.get(tempCoin) >0)
위 구문이
if(!isExhusted(tempCoin))
이렇게 작성되면 보다 읽기가 수월하다고 생각하기 때문에 저는 보통 if 내부에 존재하는 조건을 문장으로풀어쓰기위해 method로 한번 더 분리하곤 합니다.
this.count = count; | ||
} | ||
|
||
private void productValidate(int count) { |
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.
네이밍으로 validateProduct는 어떨까요
this.products = products; | ||
} | ||
|
||
public void productExist(String productName) { |
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.
getProduct라는 네이밍은 어떨까요
내부에서 검증하는 것 까지 외부에서 굳이 알 필요가 없다고 생각되네요
public int consumeProduct(String productName) { | ||
for (Product o : products) { | ||
if (o.getName().equals(productName)) { | ||
if (o.getCount() == 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.
3depth가 넘어갔네요ㅠㅠ method를 분리하는 방향을 생각해보시는게 어떨까요
public void saveLeftCoin(int amount){ | ||
if(amount >= startChange){ | ||
leftCoins = haveCoin; | ||
return; | ||
} |
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.
leftCoin이라는 메소드 명의 의미를 명확하게 파악하기 어려울 거 같아요!
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 Product(String name, int price, int count) { | ||
productValidate(count); | ||
this.name = name; | ||
this.price = price; | ||
this.count = count; | ||
} |
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.
product 클래스가 가진 것들은 잘 나눠주신 거 같습니다!
public int sell(){ | ||
count --; | ||
return price; | ||
} |
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.
오 sell을 통해서 수량을 줄이는게 명확한거 같아요!
No description provided.