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

[자판기] 김형준 미션 제출합니다. #162

Open
wants to merge 48 commits into
base: main
Choose a base branch
from

Conversation

rvlwldev
Copy link

@rvlwldev rvlwldev commented Dec 3, 2022

No description provided.

@rvlwldev rvlwldev changed the title 김형준 [자판기] 김형준 미션 제출합니다. Dec 3, 2022
}

public String toMessage() {
String prefix = "[ERROR] ";

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 = ',';

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();

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("금액은 숫자만 입력이 가능합니다."),

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(";")) {
Copy link
Member

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) {

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> 이런식으로요!

Copy link
Member

@Choi-JJunho Choi-JJunho left a comment

Choose a reason for hiding this comment

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

배워가기만하네요 ㅠㅠ
리팩토링 달려봅시다🔥

@chonahyeon
Copy link

같은 로직인데도 코드가 깔끔해서 많이 배워가요 👍👍👍

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.

4 participants