-
Notifications
You must be signed in to change notification settings - Fork 341
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
자판기 미션 리뷰 부탁드립니다!! #193
base: main
Are you sure you want to change the base?
자판기 미션 리뷰 부탁드립니다!! #193
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.
주요 로직을 어떻게 코드로 풀어낼지에 대한 고민이 깊게 보였던 것 같아요! 테스트코드도 작성해주시면 더 좋을 것 같아요 고생하셨습니다!!:)
CoinController coinController = new CoinController(); | ||
ProductController productController = new ProductController(); | ||
MoneyController moneyController = new MoneyController(); | ||
OrderController orderController = new OrderController(); |
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.
Service나 Domain 계층에 책임을 위임하지 않고, Controller에 구현하신 우진님만의 의도가 궁금합니다!
MoneyController moneyController = new MoneyController(); | ||
OrderController orderController = new OrderController(); | ||
|
||
int[] coins = coinController.initMoney(); |
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.
Collection이 아닌 배열을 사용하신 이유가 궁금합니다!
public static boolean validateEmptyStock(Products products) { | ||
//재고가 하나라도 있으면 진행 가능 | ||
return products.getProducts().stream().anyMatch(product -> product.getStock() > 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.
재고 확인 검증을 Domain이 아닌 Controller에서 하신 이유가 궁금합니다!
public static Product getProductByName(String name) { | ||
return products.stream().filter(product -> product.getName().equals(name)).findFirst() | ||
.orElse(null); | ||
} |
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를 반환하는 메서드라면, findAny()를 사용하는게 더 좋지 않을까요?? 우진님의 의견은 어떠신지 궁금해요!
} | ||
|
||
public static String input() { | ||
return readLine(); |
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.
항상 Console.readLint()을 사용해왔는데, 해당 라인처럼 더 간결하게 표현할 수 있어서 좋은 것 같아요!👍
//보유 금액만큼 동전 생성 후 출력 | ||
printCoins(coins); | ||
return coins; | ||
} |
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 receiveMoney() { | ||
printPurchasingMoneyMessage(); | ||
return inputInteger(); |
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.
Console과 같은 라이브러리뿐만 아니라, InputView와 같은 클래스까지 모두 static import 하신 의도가 궁금합니다!
InputView를 명시해주는 편이 해당 클래스 내에서 역할 및 관계를 명확히 이해할 수 있다고 생각하는데 우진님의 의견은 어떠신가요??
|
||
public void giveChange() { | ||
|
||
} |
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.
시간이 부족한 부분이 많이 아쉽네요 🥲
고생하셨습니다!
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.
다음번에는 시간을 재고 해보는 것도 좋을 것 같아요!
CoinController coinController = new CoinController(); | ||
ProductController productController = new ProductController(); | ||
MoneyController moneyController = new MoneyController(); | ||
OrderController orderController = new OrderController(); |
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 MoneyController { | ||
|
||
public int receiveMoney() { | ||
printPurchasingMoneyMessage(); | ||
return inputInteger(); | ||
} | ||
} |
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.
컨트롤러 분리가 조금 과한 감이 있는 것 같아요. 코드가 많이 길어지면 그 때 가서 분리해도 좋을 것 같습니다!
//동전 합이 total이 될 때까지 loop | ||
//0부터 size까지를 왔다갔다할 인덱스 | ||
int coinPrice = coinType[index].getAmount(); | ||
//현재 index에 해당하는 동전의 액면가 | ||
int possibleCoin = total / coinPrice; | ||
//현재 index의 동전의 최대 개수 | ||
List<Integer> numberRange = makeNumberRange(possibleCoin); | ||
//pickNumberInList의 매개변수 타입에 맞게 0부터 possibleCoin까지의 모든 수를 넣은 List | ||
if (possibleCoin > 0) { | ||
//가능한 코인 개수가 있으면 | ||
int pickedNumber = pickNumberInList(numberRange); | ||
//랜덤 돌려서 | ||
coins[index] += pickedNumber; | ||
//코인 개수에 추가 | ||
total -= coinPrice * pickedNumber; | ||
//while문 조건에 반영하기 위해 동전개수 * 액면가를 total에서 제해줌 |
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 static final String HAVING_MONEY_MESSAGE = "자판기가 보유하고 있는 금액을 입력해 주세요."; | ||
private static final String HAVING_COIN_MESSAGE = "\n자판기가 보유한 동전"; | ||
private static final String ORDER_MESSAGE = "\n상품명과 가격, 수량을 입력해 주세요."; | ||
private static final String PURCHASING_MONEY_MESSAGE = "\n투입 금액을 입력해 주세요."; | ||
private static final String PURCHASING_MONEY = "\n투입 금액: %d원"; | ||
private static final String PURCHASING_ITEM_MASSAGE = "구매할 상품명을 입력해 주세요."; | ||
private static final String printForm = "%d원 - %d개"; |
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.
운영체제에 의존적이지 않은 줄바꿈 방법을 사용하면 더 좋을 것 같아요!
for (int i = 0; i < coins.length; i++) { | ||
System.out.println(String.format(printForm, Coin.values()[i].getAmount(), coins[i])); | ||
} |
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.
stream을 활용할 수 있을 것 같아요!
우선 늦어서 죄송합니다 ㅎㅎ ㅠㅠㅜ
5시간 동안 구현해보았는데 시간이 부족해서 미완성한 것들이 있습니다 -> 잔돈 거슬러주기, 오류 처리
코드리뷰하고 이 부분도 시간날 때 이어서 작성해보겠습니다!