-
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
[자판기] 김형준 미션 제출합니다. #162
base: main
Are you sure you want to change the base?
[자판기] 김형준 미션 제출합니다. #162
Conversation
} | ||
|
||
public String toMessage() { | ||
String prefix = "[ERROR] "; |
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.
exception prefix 메시지 처리 배우고 갑니다.
private final char ORDER_PREFIX = '['; | ||
private final char ORDER_SUFFIX = ']'; | ||
private final char ORDER_SEPARATOR = ';'; | ||
private final char ORDER_INFO_SEPARATOR = ','; |
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.
validation에 사용할 문자들을 따로 빼주는 좋은 아이디어 인것 같아요
} | ||
|
||
public void showAllCoins(Change change) { | ||
HashMap<Integer, Integer> coinMap = change.getCoins(); |
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.
Change에서 tostring으로 넘겨주고 print class 에선 print만 하면 좋을 것 같아요
package vendingmachine.Constant; | ||
|
||
public enum Error { | ||
INPUT_ALLOWED_ONLY_NUMBER("금액은 숫자만 입력이 가능합니다."), |
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에 모아두는거 너무 좋네용,, 배워갑니다
public List<Product> toProducts(String userInput) { | ||
List<Product> products = new ArrayList<>(); | ||
|
||
for (String productInfo : userInput.split(";")) { |
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.
해당 객체를 다른 곳에서 사용할때 검증되지 않은 값이 들어올 수 있다고 생각되서 validation이 있으면 좋을것같아요.
} | ||
|
||
private int productSold(String productName) { | ||
for (Product productOfMenu : products) { |
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.
지금은 물건의 수가 별로 없는 예제라 괜찮지만 물건의 수가 많다면 이렇게 한바퀴 도는 것 보단 상품명을 key로 두고 key로 검색해서 처리하는게 좋을 것 같아요. HashMap<String,Product> 이런식으로요!
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.