code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -0,0 +1,68 @@
+package store.parser;
+
+import static store.message.ErrorMessage.INVALID_DATA_FORMAT;
+
+import java.util.List;
+import store.dto.ProductDto;
+import store.dto.PromotionDto;
+
+public class FileReaderParser {
+
+ private static final String COMMA_DELIMITER = ",";
+ private static final String N... | Java | ๋งค์ง ๋๋ฒ๋ฅผ ์์ํ ํด์ฃผ๋ฉด ์ข์๊ฒ๊ฐ๋ค์๐ |
@@ -0,0 +1,153 @@
+package store.parser;
+
+import static store.message.ErrorMessage.INVALID_INPUT_FORMAT_ERROR;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import store.dto.CartItemDto;
+
+public class InputParser {
+ private static final String ITEM_SEP... | Java | confirm๊ณผ ๊ฐ์ ๋ณ์๋ช
์ ์ด๋จ๊น์? |
@@ -0,0 +1,128 @@
+package store.parser;
+
+import static store.constants.PromotionConstants.NO_PROMOTION_SUFFIX;
+import static store.constants.PromotionConstants.PROMOTION_SUFFIX;
+import static store.message.ErrorMessage.EMPTY_DATA;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Li... | Java | depth๊ฐ ๋ค์ ๊น์ ๊ฒ ๊ฐ์์!
๋ชจ๋ํ๋ฅผ ํด๋ณด๋๊ฑด ์ด๋จ๊น์? |
@@ -0,0 +1,112 @@
+package store.custom.service.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+import store.custom.model.order.OrderSheet;
+import store.custom.model.order.OrderedProduct;
+import store.custom.model.product.Product;
+import store.custom.model.product.Products;
+
+public class ProductsEd... | Java | [์ง๋ฌธ] `OrderSheetEditor`์ ๊ฒฝ์ฐ์๋ ๊ฐ์ฒด๋ฅผ ์ง์ ์์ฑํ์ฌ ์ฌ์ฉํ๋ ๋ฐฉ์์ ์ ํํ์
จ๋๋ฐ, `ProductsEditor`๋ ์ ํธ๋ฆฌํฐ ํด๋์ค์ ๊ฐ์ ํํ๋ก ์์ฑํ ์ด์ ๊ฐ ์์๊น์? |
@@ -0,0 +1,35 @@
+package store.custom.model.product;
+
+public class Product {
+ private final String name;
+ private final int price;
+ private int quantity;
+ private final String promotion;
+
+ public Product(String name, int price, int quantity, String promotion) {
+ this.name = name;
+ ... | Java | `product`์ `promotion` ํ๋๊ฐ `null` ๊ฐ์ ๊ฐ์ง ์ ์์ด Editor ๋ก์ง๋ค์์ `null` ์ ๋ํ ์ฒ๋ฆฌ๊ฐ ํ์ํฉ๋๋ค.
`Optional`์ ์ฌ์ฉํ์ฌ `promotion` ํ๋๊ฐ ๊ฐ์ด ์๋ ๊ฒฝ์ฐ๋ฅผ ๋ช
์์ ์ผ๋ก ์ฒ๋ฆฌํ๊ฑฐ๋, "" ์ ๊ฐ์ ๊ธฐ๋ณธ ๊ฐ์ ๊ฐ์ง๋๋ก ํ๋ฉด ์ด๋จ๊น์? |
@@ -0,0 +1,21 @@
+package store.custom.service.filehandler;
+
+import static store.custom.validator.CustomErrorMessages.FILE_READING_FAIL;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import store.custom.validator.Validator;
+
+public class FileReader ... | Java | readAllLines๋ผ๋ ๋ฉ์๋๊ฐ ์์๋ค์! ์ ๋ while๋ฌธ์ผ๋ก ํ์ผ์ ๋๊น์ง ์ฝ์ด์ค๋๋ก ํ๋๋ฐ, ์ฌ์ฉํ์ ๋ฐฉ๋ฒ์ด ์ฐธ ๊ฐ๋จํ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,112 @@
+package store.custom.service.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+import store.custom.model.order.OrderSheet;
+import store.custom.model.order.OrderedProduct;
+import store.custom.model.product.Product;
+import store.custom.model.product.Products;
+
+public class ProductsEd... | Java | ์ ๋ ํ๋ก๋ชจ์
์ํ๋ง ์๋ ๊ฒฝ์ฐ ์ผ๋ฐ ์ํ์ ์ถ๊ฐํ๋ ๊ธฐ๋ฅ์ ์ถ๊ฐํ์ง ๋ชปํ๋๋ฐ, ๊ทธ๋์ ๊ทธ๋ฐ์ง ๋ ์ธ์์ ์ด์์...๐
๊ผผ๊ผผํ ๋ก์ง์์ ๋ง์ด ๋ฐฐ์๋๋ค. |
@@ -0,0 +1,105 @@
+package store.custom.validator;
+
+import static store.custom.constants.RegexConstants.PRODUCT_ORDER_REGEX;
+import static store.custom.constants.StringConstants.RESPONSE_NO;
+import static store.custom.constants.StringConstants.RESPONSE_YES;
+import static store.custom.validator.CustomErrorMessages.... | Java | ์ ๊ท ํํ์์ ์ฌ์ฉํ๋ ์ ๋ง ๊ฐ๋จํ๊ฒ ์ฒ๋ฆฌ๋๋ค์!! ๋งค๋ฒ ๋๋ผ๋ ๊ฑฐ์ง๋ง ํจ์จ์ ์ธ ๋ฐฉ๋ฒ์ ์ ์ฌ์ฉํ์๋ ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,99 @@
+package store.custom.service.maker;
+
+import static store.custom.constants.NumberConstants.NOT_FOUND;
+import static store.custom.constants.StringConstants.AFTER_PROMOTION_END;
+import static store.custom.constants.StringConstants.BEFORE_PROMOTION_START;
+
+import java.util.ArrayList;
+import java.ut... | Java | ์ ๋ฉ์๋๋ช
์ฌ๊ธฐ๋์...! |
@@ -0,0 +1,153 @@
+package store.custom.service.editor;
+
+import static store.custom.constants.StringConstants.AFTER_PROMOTION_END;
+import static store.custom.constants.StringConstants.BEFORE_PROMOTION_START;
+import static store.custom.constants.StringConstants.RESPONSE_NO;
+import static store.custom.constants.Stri... | Java | OrderSheetEditor ํด๋์ค ๋ถ๋ถ์ ์ฐธ๊ณ ํ๋ฉด ์ ๊ฐ ์ฌ์
๋ ฅ๊ณผ ๊ด๋ จํด ๊ณ ๋ฏผํ๋ ๋ถ๋ถ์ด ์ผ๋ถ ํด๊ฒฐ๋ ๊ฒ ๊ฐ์์.
์ถ๊ฐ๋ก, ์ ์ฒด์ ์ผ๋ก ์ ์ ์ ์ฝํ๋ ์ฝ๋์ ๋ก์ง์ ๊ฐํํ๊ณ ๊ฐ๋๋ค. |
@@ -0,0 +1,35 @@
+package store.custom.model.product;
+
+public class Product {
+ private final String name;
+ private final int price;
+ private int quantity;
+ private final String promotion;
+
+ public Product(String name, int price, int quantity, String promotion) {
+ this.name = name;
+ ... | Java | promotion ํ๋๋ ํ๋ก๋ชจ์
๊ฐ์ฒด๋ฅผ ์ง์ ์ฐธ์กฐํ๋๋ก ํ๋ฉด ์ด๋จ๊น์? |
@@ -0,0 +1,153 @@
+package store.custom.service.editor;
+
+import static store.custom.constants.StringConstants.AFTER_PROMOTION_END;
+import static store.custom.constants.StringConstants.BEFORE_PROMOTION_START;
+import static store.custom.constants.StringConstants.RESPONSE_NO;
+import static store.custom.constants.Stri... | Java | OrderSheetEditor์์ ๋ง์ ์ญํ ์ ํ๊ณ ์๋๋ฏ ํฉ๋๋ค ์ฃผ๋ฌธ์ ํธ์ง, ํ๋ก๋ชจ์
์ ์ฉ, ์ฌ๊ณ ๊ด๋ฆฌ ๋ฑ์ ๊ธฐ๋ฅ์ ๊ฐ๊ฐ ๋ถ๋ฆฌํ๋ ๊ฒ ์ด๋จ๊น์? ์ฌ์ค ์ด๋ฐ ๋ถ๋ถ์์ ์ ๋ ๊ณ ๋ฏผ์ด ๋ง์ ํฐ๋ผ ๋ผ์ ค๋์ ๋ค๋ฅธ ์๊ฒฌ์ด ์๋ค๋ฉด ๋ฃ๊ณ ์ถ์ต๋๋ค! |
@@ -0,0 +1,63 @@
+package store.custom.model.order;
+
+public class OrderedProduct {
+ private final String name;
+ private int quantity;
+ private int totalPrice;
+ private String promotion;
+ private int buy;
+ private int get;
+
+ public OrderedProduct(String name, int quantity, int totalPrice, ... | Java | setter๋ฅผ ์ด์ด๋๋๊ฒ์ ์ข์ง ์๋ค๊ณ ๋ฐฐ์ ๋ ๊ฒ ๊ฐ์ต๋๋ค! ์ฌ๊ณ ๋ฅผ ์ฐจ๊ฐํ๋ค๋๊ฐ ๋ค๋ฅธ ๊ฐ๋ค์ ๊ฐ์ฒด๋ฅผ ์์ฑํ ๋ ํ ๋นํ๋ค๋๊ฐ ํ๋ ๋ก์ง์ ๋ฐ๋ก ๋ง๋ค์ด์ ์ฒ๋ฆฌํ๋ฉด ์ด๋จ๊น์? |
@@ -0,0 +1,58 @@
+package store.custom.service.parser;
+
+import static store.custom.constants.RegexConstants.SINGLE_COMMA;
+import static store.custom.constants.StringConstants.NO_PROMOTION;
+
+import java.util.ArrayList;
+import java.util.List;
+import store.custom.model.product.Product;
+import store.custom.model.pr... | Java | ๋ณ๊ฑฐ ์๋ ๋ถ๋ถ์ด๊ธด ํ๋ฐ, ์ธ๋ฑ์ค๋ฅผ ํ๋์ฝ๋ฉํ๋ ๊ฒ ๋ณด๋ค ์์๋ก ๋นผ์ nameIndex, priceIndex ์ฒ๋ผ ๋์์ผ๋ฉด ๋ ์ข์์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,153 @@
+package store.custom.service.editor;
+
+import static store.custom.constants.StringConstants.AFTER_PROMOTION_END;
+import static store.custom.constants.StringConstants.BEFORE_PROMOTION_START;
+import static store.custom.constants.StringConstants.RESPONSE_NO;
+import static store.custom.constants.Stri... | Java | OrderSheetEditor์ ์ญํ ์ด ๋ง๋ค๋ ์ ์์ ์ ๋ ๋น์ทํ ์๊ฐ์
๋๋ค!
+ **3์ฃผ์ฐจ ํผ๋๋ฐฑ ์ค ๊ฐ์ฒด๋ฅผ ๊ฐ์ฒด๋ต๊ฒ ์ฌ์ฉํ๋ค** ํผ๋๋ฐฑ์ด ๋ ์ฌ๋์ด์. ์ผ๋ถ ๋ก์ง ์ค์์๋ ๋ชจ๋ธ ๋ด๋ถ์์ ์ฑ
์์ ๊ฐ์ ธ๊ฐ ์ ์๋ ๊ฒ๋ค๋ ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
๋ํ์ ์ผ๋ก ์๋ ๋ฉ์๋๊ฐ ๊ทธ๋ฐ ๊ฒ ๊ฐ์์!
```
private void setPromotionIfExist(OrderedProduct orderProduct, Product product) {
if (product.getPromotion() != null) {
orderP... |
@@ -0,0 +1,63 @@
+package store.custom.model.order;
+
+public class OrderedProduct {
+ private final String name;
+ private int quantity;
+ private int totalPrice;
+ private String promotion;
+ private int buy;
+ private int get;
+
+ public OrderedProduct(String name, int quantity, int totalPrice, ... | Java | ์์ ์ธ๊ธ๋๋ฆฐ 3์ฃผ์ฐจ ํผ๋๋ฐฑ ๊ฐ์ฒด๋ฅผ ๊ฐ์ฒด๋ต๊ฒ ์ฌ์ฉํ๊ธฐ์ ์ฐ๊ด๋ ๋ฆฌ๋ทฐ๊ฐ ์๋๊น ์ถ๋ค์!
3์ฃผ์ฐจ ํผ๋๋ฐฑ ์ค ๋ฐ์ท
>Lotto์์ ๋ฐ์ดํฐ๋ฅผ ๊บผ๋ด์ง(get) ๋ง๊ณ ๋ฉ์์ง๋ฅผ ๋์ง๋๋ก ๊ตฌ์กฐ๋ฅผ ๋ฐ๊ฟ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ง๋ ๊ฐ์ฒด๊ฐ ์ผํ๋๋ก ํ๋ค. ์ด์ฒ๋ผ Lotto ๊ฐ์ฒด์์ ๋ฐ์ดํฐ๋ฅผ ๊บผ๋ด(get) ์ฌ์ฉํ๊ธฐ๋ณด๋ค๋, ๋ฐ์ดํฐ๊ฐ ๊ฐ์ง๊ณ ์๋ ๊ฐ์ฒด๊ฐ ์ค์ค๋ก ์ฒ๋ฆฌํ ์ ์๋๋ก ๊ตฌ์กฐ๋ฅผ ๋ณ๊ฒฝํด์ผ ํ๋ค. ์๋์ ๊ฐ์ด ๋ฐ์ดํฐ๋ฅผ ์ธ๋ถ์์ ๊ฐ์ ธ์(get) ์ฒ๋ฆฌํ์ง ๋ง๊ณ , ๊ฐ์ฒด๊ฐ ์์ ์ ๋ฐ์ดํฐ๋ฅผ ์ค์ค๋ก ์ฒ๋ฆฌํ๋๋ก ๋ฉ์์ง๋ฅผ ๋์ง๊ฒ ํ๋ค. |
@@ -0,0 +1,190 @@
+package store.custom.controller;
+
+import static store.custom.constants.StringConstants.PRODUCTS_FILE_PATH;
+import static store.custom.constants.StringConstants.PROMOTIONS_FILE_PATH;
+import static store.custom.constants.StringConstants.RESPONSE_YES;
+
+import java.util.List;
+import store.custom.m... | Java | while(true)์ try-catch๊ฐ ๋ฐ๋ณต๋๋๋ฐ, ๋ฐํ๊ฐ์ด ๊ฐ์ ๊ฒ ๊ฐ์์์! ํธ๋ค๋ฌ๋ก ๋นผ์ ์ฒ๋ฆฌํ๋ฉด ๋ ์ ์ฐํ ์ฝ๋๊ฐ ๋์ง ์์๊น ์ถ์ต๋๋ค |
@@ -0,0 +1,63 @@
+package store.custom.model.order;
+
+public class OrderedProduct {
+ private final String name;
+ private int quantity;
+ private int totalPrice;
+ private String promotion;
+ private int buy;
+ private int get;
+
+ public OrderedProduct(String name, int quantity, int totalPrice, ... | Java | ๋์ํฉ๋๋ค! ๊ฐ์ฒด๊ฐ ์๋์ ์ธ ๊ฒ์ด ์๋, '๋ฅ๋์ '์ธ ์ธ์คํด์ค๋ผ๋ ๊ฒ์ ๊ณ ๋ คํ์๋ฉด ๋ ์ข์ ์ฝ๋๊ฐ ๋ ๊ฒ ๊ฐ์์ |
@@ -0,0 +1,35 @@
+package store.custom.model.product;
+
+public class Product {
+ private final String name;
+ private final int price;
+ private int quantity;
+ private final String promotion;
+
+ public Product(String name, int price, int quantity, String promotion) {
+ this.name = name;
+ ... | Java | ๋์ํฉ๋๋ค! |
@@ -0,0 +1,153 @@
+package store.custom.service.editor;
+
+import static store.custom.constants.StringConstants.AFTER_PROMOTION_END;
+import static store.custom.constants.StringConstants.BEFORE_PROMOTION_START;
+import static store.custom.constants.StringConstants.RESPONSE_NO;
+import static store.custom.constants.Stri... | Java | ๋์ํฉ๋๋ค! ํ์ฌ ํด๋์ค์์ ์ญํ ์ ๋ง์ด ๊ฐ๊ณ ์์ด์ ๊ฐ์ฒด ๋ด๋ถ์์ ์ฒ๋ฆฌํ๊ฑฐ๋, ๋ถ๋ฆฌํ๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค |
@@ -0,0 +1,190 @@
+package store.custom.controller;
+
+import static store.custom.constants.StringConstants.PRODUCTS_FILE_PATH;
+import static store.custom.constants.StringConstants.PROMOTIONS_FILE_PATH;
+import static store.custom.constants.StringConstants.RESPONSE_YES;
+
+import java.util.List;
+import store.custom.m... | Java | ์ธ๋ฑ์ค๋ก ์ ๊ทผํ๊ธฐ ๋ณด๋ค๋,,, ์์๋ก ์ ๊ทผํด๋ ์ข์ง ์์์๊น์? ๋ก์ง์์ผ๋ก๋ ๊ฐ ์์๊ฐ ์์ผ๋ก ๋ค์ด์ค์ง๋ง ๊ทธ๊ฑธ ์ดํดํ๋ ค๋ฉด ์ฝ๋๋ฅผ ๊ณ์ ๋ฐ๋ผ๊ฐ์ผํ๋๊น,,,
๋ ๊ฐ์ ๋ค๋ฅธ ๊ฐ์ฒด๋ฅผ ์ ๊ทผํด์ผํ๋ค๋๊ฒ ๋ฌธ์ ๊ธด ํ๋ฐ, ์ด์ฐจํผ ๋ค์๋ ๋ ๊ฐ์ ํ๋ผ๋ฏธํฐ๋ฅผ ๊ณ์ ์ฐ๊ณ , ๋ ๋ฐ๋ณต์ํค๋ ๊ฒ ๊ฐ์์promotionResults๋ฅผ ๋ฝ์ ๋ orderSheet์ ์์์ ๋ด์ฉ์ ํฌํจํ๋ ๋ฌด์ธ๊ฐ๋ก ๋งคํ์ํค๊ฑฐ๋ ํ ์๋ ์์ง ์์๊น์? |
@@ -0,0 +1,58 @@
+package store.custom.service.parser;
+
+import static store.custom.constants.RegexConstants.SINGLE_COMMA;
+import static store.custom.constants.StringConstants.NO_PROMOTION;
+
+import java.util.ArrayList;
+import java.util.List;
+import store.custom.model.product.Product;
+import store.custom.model.pr... | Java | ์๊ฒ๋ ์ธ๋ฑ์ค ์ ๊ทผ๋ณด๋ค ์์ ์ ๊ทผ์ผ๋ก ๋ฐ๊พธ๋๊ฒ ๋ ์ง๊ด์ ์ด๊ณ ํจ์จ์ ์ผ ๊ฒ ๊ฐ์์ |
@@ -0,0 +1,112 @@
+package store.custom.service.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+import store.custom.model.order.OrderSheet;
+import store.custom.model.order.OrderedProduct;
+import store.custom.model.product.Product;
+import store.custom.model.product.Products;
+
+public class ProductsEd... | Java | ์ข ๋ ๋ช
๋ฃํ ์ฝ๋ ํ๋ฆ์ด ์์๊น์? ์... ArrayList์ฌ์ ๋ ๋นํจ์จ์ ์ผ ์๋ ์์ง๋ง promotion์ด ์๋ ์ํ๋ค๋ง ๋ฐ๋ณต์ํค๋ฉด์ ์ผ๋ฐ ์ฌ๊ณ ๋ฅผ ๊ฒ์ํ๊ณ ์์ผ๋ฉด ์์ฑํ๋...?๊ฒ๋ ์ฌ๋ฐ์ง ์์๊น์? |
@@ -0,0 +1,29 @@
+package store.custom.model.product;
+
+import static store.custom.validator.CustomErrorMessages.INVALID_INDEX;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Products {
+ private final List<Product> productCatalog;
+
+ public Products(List<Product> productCatalog) {
+ ... | Java | ์ ๊ฐ ์ผ๊ธ์ปฌ๋ ์
์ ์ ๋ชจ๋ฅด๊ธด ํ์ง๋ง,,, ์ ๊ฐ ์ดํดํ ๋ฐ๋ก๋ ์ข ๋ ๋ฉฑํํ๊ฒ ์บก์ํํ๋๊ฒ ์ฅ์ ์ธ ๊ฒ์ผ๋ก ์ดํดํ๊ณ ์์ด์! ๊ทผ๋ฐ ์ผ๊ธ ์ปฌ๋์
์ ๊ตฌํ์ด ๋ด๋ถ์ ์์๋ฅผ ์ธ๋ถ๋ก ๋ฐ์ถ์ํค๋ ๊ฒ๋ง ์๋๊ฒ ์คํ๋ ค ์บก์ํ, ์๋ํ๋ฅผ ํด์น ์ ์์ง ์์๊น์? ์ธ๋ถ์์ product๋ products์์ ํ์ฉํ๋ ์ฌ๋ฌ ๋ฉ์๋๋ค ์ญ์ ๋ชจ๋ธ์ ์ฑ
์ ์๋์ ์์ผ๋๊น ๋ด๋ถ๋ก ํฌํจ์ํค๋ ๊ฒ๋ ์ข์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,190 @@
+package store.custom.controller;
+
+import static store.custom.constants.StringConstants.PRODUCTS_FILE_PATH;
+import static store.custom.constants.StringConstants.PROMOTIONS_FILE_PATH;
+import static store.custom.constants.StringConstants.RESPONSE_YES;
+
+import java.util.List;
+import store.custom.m... | Java | ํธ๋ค๋ฌ ์๊ฐ์ ๋ชปํ๋ค์! ์ข์ ๋ฐฉ๋ฒ ์๋ ค์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค! |
@@ -0,0 +1,63 @@
+package store.custom.model.order;
+
+public class OrderedProduct {
+ private final String name;
+ private int quantity;
+ private int totalPrice;
+ private String promotion;
+ private int buy;
+ private int get;
+
+ public OrderedProduct(String name, int quantity, int totalPrice, ... | Java | ๊ฐ์ฒด์ ๋ํ ๊ณต๋ถ๋ฅผ ๋ ํด๋ด์ผ๊ฒ ์ต๋๋ค! ์๋ ค์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค! |
@@ -0,0 +1,35 @@
+package store.custom.model.product;
+
+public class Product {
+ private final String name;
+ private final int price;
+ private int quantity;
+ private final String promotion;
+
+ public Product(String name, int price, int quantity, String promotion) {
+ this.name = name;
+ ... | Java | ๊ทธ ์๊ฐ์ ๋ชปํด๋ดค๋ค์! ํ์คํ ํ๋ก๋ชจ์
๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ฉด ๋ ์ข์ ๊ฒ ๊ฐ๋ค์! |
@@ -0,0 +1,153 @@
+package store.custom.service.editor;
+
+import static store.custom.constants.StringConstants.AFTER_PROMOTION_END;
+import static store.custom.constants.StringConstants.BEFORE_PROMOTION_START;
+import static store.custom.constants.StringConstants.RESPONSE_NO;
+import static store.custom.constants.Stri... | Java | OrdersheetEditor์ ์ญํ ์ ์ด๋ฏธ ์์ฑ๋ ์ฃผ๋ฌธ์์ ๋ณ๊ฒฝ(์ฃผ๋ฌธ์์ ์ด๊ธฐ ์ค์ , ํ๋ก๋ชจ์
๋ด์ฉ ์ ์ฉ)์ผ๋ก ์๊ฐํ๊ณ ์์ฑํ์๋๋ฐ, ๊ฐ์ฒด๊ฐ ๊ฐ์ง ์ ์๋ ์ญํ ์ ๋ฒ์๋ฅผ ์ ํ์
ํ์ง ๋ชปํด ๊ธฐ๋ณธ์ ์ธ ๊ฒ์ ์ ์ธํ๊ณ editor์ ๋ชจ๋ ์์ฑํ์์ต๋๋ค. ๋ชจ๋ธ ๋ด๋ถ์์ ์ฑ
์์ ๊ฐ์ ธ๊ฐ ์ ์๋ ๋ถ๋ถ์ ๊ณ ๋ฏผํด ๋ณด์์ผ๊ฒ ์ต๋๋ค. ์ข์ ์๊ฒฌ ๊ฐ์ฌํฉ๋๋ค! |
@@ -0,0 +1,153 @@
+package store.custom.service.editor;
+
+import static store.custom.constants.StringConstants.AFTER_PROMOTION_END;
+import static store.custom.constants.StringConstants.BEFORE_PROMOTION_START;
+import static store.custom.constants.StringConstants.RESPONSE_NO;
+import static store.custom.constants.Stri... | Java | ์นญ์ฐฌํด์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค! |
@@ -0,0 +1,369 @@
+# 4์ฃผ ์ฐจ - ํธ์์
+
+---
+## ๊ธฐ๋ฅ ์๊ตฌ์ฌํญ
+
+---
+
+๊ตฌ๋งค์์ ํ ์ธ ํํ๊ณผ ์ฌ๊ณ ์ํฉ์ ๊ณ ๋ คํ์ฌ ์ต์ข
๊ฒฐ์ ๊ธ์ก์ ๊ณ์ฐํ๊ณ ์๋ดํ๋ ๊ฒฐ์ ์์คํ
์ ๊ตฌํํ๋ค.
+
+* ์ฌ์ฉ์๊ฐ ์
๋ ฅํ ์ํ์ ๊ฐ๊ฒฉ๊ณผ ์๋์ ๊ธฐ๋ฐ์ผ๋ก ์ต์ข
๊ฒฐ์ ๊ธ์ก์ ๊ณ์ฐํ๋ค.
+ * ์ด๊ตฌ๋งค์ก์ ์ํ๋ณ ๊ฐ๊ฒฉ๊ณผ ์๋์ ๊ณฑํ์ฌ ๊ณ์ฐํ๋ฉฐ, ํ๋ก๋ชจ์
๋ฐ ๋ฉค๋ฒ์ญ ํ ์ธ ์ ์ฑ
์ ๋ฐ์ํ์ฌ ์ต์ข
๊ฒฐ์ ๊ธ์ก์ ์ฐ์ถํ๋ค.
+* ๊ตฌ๋งค ๋ด์ญ๊ณผ ์ฐ์ถํ ๊ธ์ก ์ ๋ณด๋ฅผ ์์์ฆ์ผ๋ก ์ถ๋ ฅํ๋ค.
+* ์์์ฆ ์ถ๋ ฅ ํ ์ถ๊ฐ ๊ตฌ๋งค๋ฅผ ์งํํ ์ง ๋๋ ์ข
๋ฃํ ์ง๋ฅผ ์ ํํ ์ ์๋ค.
+* ์ฌ... | Unknown | ์ด๋ฒ ๋ฏธ์
์ด ์ ๋ง ๋ณต์กํด์ ์ด๋ ค์ ๋๋ฐ ์ ๋ ์ค๊ณ๋ฅผ ์งํํ ๋ ํ๋ก์ฐ ์ฐจํธ์ ๋น์ทํ๊ฒ ๋์ ๊ณผ์ ์ ์ ๋ฆฌํ๊ณ ๊ฐ๋ฐ์ ์งํํ๋๊ฒ ๊ฐ์๋ฐ ๋ฌธ์ํ๋๋ ๋น์ทํ๊ฒ ์งํํ ๊ฒ ๋ณด๊ณ ๋๋๋ค์ |
@@ -0,0 +1,137 @@
+package store.controller;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.util.ArrayList;
+import java.util.List;
+import store.domain.BuyProductParser;
+import store.domain.BuyProducts;
+import store.domain.FileReader;
+import store.domain.CustomerReceipt;
+import store.domain.Produ... | Java | ๋ค๋ฅธ ์ฌ๋๋ค์ ์ฝ๋๋ฅผ ๋ชฐ๋๋ชฐ๋ ๋ดค์๋ ์ด๋ฐ์ฉ์ผ๋ก ์ฒ๋ฆฌํด์ ๋ณ์๋ฅผ ์ค์ด๋ ๋ฐฉ๋ฒ๋ ์๋๊ตฐ์. ์๊ฐ์ ๋ฐ๋ผ ์ข์์๋ ์๊ณ ์์ข๋ค๊ณ ์๊ฐํ ์๋ ์์ง๋ง ์ฝ๋๋ณด๋ค๊ฐ ์๊ฐ๋์ ๋ฃ์ด๋๊ฒ์
```suggestion
do {
showInventory(products);
BuyProducts buyProducts = buyProducts(promotions, products);
CustomerReceipt customerReceipt = makeCustomerReceipt(products, bu... |
@@ -0,0 +1,137 @@
+package store.controller;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.util.ArrayList;
+import java.util.List;
+import store.domain.BuyProductParser;
+import store.domain.BuyProducts;
+import store.domain.FileReader;
+import store.domain.CustomerReceipt;
+import store.domain.Produ... | Java | ๋ค์ .equals(YES)๋ผ๊ณ ํ๋ ๊ฒฝ์ฐ ํ๋จ์ controller์์ ์งํํ๋ ๊ฒ๋ณด๋ค๋ view์์ YES๋ฉด true๋ฅผ ๋ฃ์ด controller์ ์ฑ
์์ ์ค์ฌ์ฃผ๋๊ฒ์ ๋ํด์๋ ์ด๋ป๊ฒ ์๊ฐํ์๋์? |
@@ -0,0 +1,137 @@
+package store.controller;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.util.ArrayList;
+import java.util.List;
+import store.domain.BuyProductParser;
+import store.domain.BuyProducts;
+import store.domain.FileReader;
+import store.domain.CustomerReceipt;
+import store.domain.Produ... | Java | FileReader๋ฅผ ์์ฑํ๋ ๊ฒ๋ณด๋ค ์์กด์ฑ ์ฃผ์
์ ํตํด ์ฌ์ฉํ์๋ฉด ์ถํ ํ๋ก๋ชจ์
์ ๊ฐ์ ธ์ค๋ ๋ฐฉ๋ฒ์ด ๋ฐ๋์ด๋ ์ฝ๊ฒ ์์ ์ด ๊ฐ๋ฅํด์ง ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,41 @@
+package store.domain;
+
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import store.domain.vo.PromotionType;
+
+public class Promotions {
+
+ private static final int BUY_INDEX = 1;
+ private static final int FREE_GET_INDEX = 2;
+ private static final i... | Java | List<List<String>>์ผ๋ก ์ ๋ณด๋ฅผ ๋ฝ์๋ด๋ ๊ฒ์ ๋๋ฉ์ธ์ ์ญํ ์ด ์๋ view์ ์ญํ ์ ๋ ๊ฐ๊น์ด ๊ฒ ๊ฐ์ต๋๋ค. View์์ ์ด๋์ ๋์ ๋ฐ์ดํฐ๋ฅผ ๊ฐ๊ณตํ ํ DTO๋ฅผ ํตํด product๋ฅผ ์์ฑํ๋ ๊ฒ์ ์ด๋จ๊น์? |
@@ -0,0 +1,60 @@
+package store.domain;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import store.domain.vo.ProductQuantity;
+import store.domain.vo.PromotionType;
+
+public class Promotion {
+
+ private final PromotionType promotionType;
+ private final ProductQua... | Java | ํ๋ก๋ชจ์
์์ฑ ๊ณผ์ ์ ๋ณด๋ฉด ํ์ฌ ์๊ฐ์ ๋ง์ถฐ ํ๋ก๋ชจ์
์ ์ฉ์ ์ ํ๋๋ฐ ์ฌ๊ณ ๋ฅผ ๋ฃ๋ ์๊ฐ๋์ ๋ฌผํ์ ์ฌ๋ ์๊ฐ์ด ๋ค๋ฅธ ๊ฒฝ์ฐ ๋ฌธ์ ๊ฐ ์๊ธธ ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,137 @@
+package store.controller;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.util.ArrayList;
+import java.util.List;
+import store.domain.BuyProductParser;
+import store.domain.BuyProducts;
+import store.domain.FileReader;
+import store.domain.CustomerReceipt;
+import store.domain.Produ... | Java | ์ด๋ ๊ฒ ์ฌ๋ฌ๋ฒ ํธ์ถ์ด ๋๋ค๋ฉด IO์์
์ด ๋์ด๋๊ฒ ๋๋ฉด์ ์ฑ๋ฅ์ ์ผ๋ก ์์ฌ์์ด ์๊ธธ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค. List๋ฅผ ํตํด ํ๋ฒ์ ๋ณด๋ธ ํ IO์์
์ ํตํด ์ฒ๋ฆฌํ์๋๊ฒ์ ์ด๋ค๊ฐ์? |
@@ -0,0 +1,76 @@
+package store.view;
+
+import java.util.List;
+import store.view.dto.response.BuyProductResponse;
+import store.view.dto.response.ErrorResponse;
+import store.view.dto.response.FreeProductResponse;
+import store.view.dto.response.ProductCalculateResponse;
+
+public class OutputView {
+
+ private st... | Java | format์ ์์๋ฅผ ํตํด ์ฒ๋ฆฌํ๋ ๊ฒ์ ์ด๋ค๊ฐ์?
๋ง์ฝ ์ถ๋ ฅ ํ์์ด ์ข ๋ฌ๋ผ์ง๋ค๋ฉด ์์ ์ด ๋์ฑ ๋ฒ๊ฑฐ๋ก์ธ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,76 @@
+package store.view;
+
+import java.util.List;
+import store.view.dto.response.BuyProductResponse;
+import store.view.dto.response.ErrorResponse;
+import store.view.dto.response.FreeProductResponse;
+import store.view.dto.response.ProductCalculateResponse;
+
+public class OutputView {
+
+ private st... | Java | System.lineSeparator๋ฅผ ํตํ ์ค๋ฐ๊ฟ ์ฒ๋ฆฌ ๊ต์ฅํ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,46 @@
+package store.domain.service;
+
+import java.util.ArrayList;
+import java.util.List;
+import store.domain.BuyProducts;
+import store.domain.Product;
+import store.domain.Products;
+import store.view.dto.response.PromotionResponse;
+
+public class PromotionChecker {
+
+ private static final int ZERO... | Java | ํ๋ก๋ชจ์
์ ํ์ธํ๋ ๋ถ๋ถ์ ๋ฐ๋ก ๋ฝ์ ์ด์ ๊ฐ ์์๊น์? |
@@ -0,0 +1,137 @@
+package store.controller;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.util.ArrayList;
+import java.util.List;
+import store.domain.BuyProductParser;
+import store.domain.BuyProducts;
+import store.domain.FileReader;
+import store.domain.CustomerReceipt;
+import store.domain.Produ... | Java | false์ isFreePromotion์ enum์ ํตํ ์ํ๋ฅผ ๋ํ๋ด๋ ์ด๊ฑฐํ์ผ๋ก ํ๋ ๊ฒ์ ์ด๋จ๊น์? |
@@ -0,0 +1,137 @@
+package store.controller;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.util.ArrayList;
+import java.util.List;
+import store.domain.BuyProductParser;
+import store.domain.BuyProducts;
+import store.domain.FileReader;
+import store.domain.CustomerReceipt;
+import store.domain.Produ... | Java | ์ด ๋ถ๋ถ์ outputView์์ ์์๋ฅผ ๊ด๋ฆฌํ๋ ๊ฒ์ด ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค |
@@ -0,0 +1,137 @@
+package store.controller;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.util.ArrayList;
+import java.util.List;
+import store.domain.BuyProductParser;
+import store.domain.BuyProducts;
+import store.domain.FileReader;
+import store.domain.CustomerReceipt;
+import store.domain.Produ... | Java | while์กฐ๊ฑด ์์ true๋ฅผ ๋ฃ๋ ๋ฐฉ์์ ๋งค์ฐ ์ข์ง ๋ชปํ ๋ฐฉ์์ด๋ผ๊ณ ์๊ณ ์์ต๋๋ค. ๋ฐ๋ก boolean๊ฐ์ ์ฌ์ฉํด์ ์กฐ๊ฑด์ ๋ฃ๋ ๊ฒ์ด ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค |
@@ -0,0 +1,63 @@
+package store.domain;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import store.domain.exception.ProductErrorCode;
+import store.domain.exception.ProductException;
+
+... | Java | Hash์ ๊ฒฝ์ฐ ์ฌ๊ธฐ์ ์ธ ์๊ฐ๋ณต์ก๋๋ก ์ข์ง๋ง ํน์ํ ์ํฉ์์๋ Hash์ ๊ฒฝ์ฐ ๊ต์ฅํ ๋๋ ค์ง ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ๋ฐ๋ผ์ Hash๋ณด๋จ ๋๋ฆฌ์ง๋ง ์์ ์ ์ธ ์ฑ๋ฅ์ ๊ฐ์ง๋ TreeMap๋ ์ถ์ฒ๋๋ฆฝ๋๋ค. ๊ทผ๋ฐ TreeMap์ ์ฌ์ฉํ๋ฉด ์์์ ๋ค๋ฅด๊ฒ ์ ๋ ฌ๋๋ค๋ ๋จ์ ์ด ์์ต๋๋ค. |
@@ -0,0 +1,168 @@
+## ๊ณ ๋ฏผ์ฌํญ
+
+**๊ณ ๋ฏผ**
+~~~
+๊ตฌํ์ ํ์ํ ์ํ ๋ชฉ๋ก๊ณผ ํ์ฌ ๋ชฉ๋ก์ ํ์ผ ์
์ถ๋ ฅ์ ํตํด ๋ถ๋ฌ์จ๋ค.
+src/main/resources/products.md๊ณผ
+src/main/resources/promotions.md ํ์ผ์ ์ด์ฉํ๋ค.
+~~~
+* ๋งํฌ๋ค์ด ํ์ผ์ ์๋ ๋ด์ฉ์ ์ด๋ป๊ฒ ๋ถ๋ฌ์ ์ฝ๋์ ์ ์ฉ์ํฌ ์ ์์๊น?
+
+**ํด๊ฒฐ ๊ณผ์ **
+* BufferedReader ๋ฅผ ์ฌ์ฉํ์ฌ ํ์ผ ๋ด์ฉ์ ํ ์ค์ฉ ์
๋ ฅ๋ฐ๋ ํ์์ผ๋ก ํ๋ค.
+* ๋ฐ์์จ ์ค์ ์ผํ(,)๋ก ๊ตฌ๋ถํ์ฌ ๋ถ๋ฆฌํ๋ค
+* ๋ถ๋ฆฌํ ๋ด์ฉ์ ์๋ง๊ฒ ์์๊ฐ ... | Unknown | README์ ๋ชจ๋ ์์ฑํ์ง ์๊ณ , ์ฌ๋ฌ๊ฐ๋ก ๋ถ๋ฆฌํ์ ์ด์ ๊ฐ ์์๊น์?? |
@@ -1,7 +1,19 @@
package store;
+import store.controller.StoreController;
+import store.domain.service.MemberShipCalculator;
+import store.domain.service.PromotionCalculator;
+import store.view.InputView;
+import store.view.OutputView;
+
public class Application {
public static void main(String[] args) {
... | Java | controller ๋ด๋ถ์์ ์์ฑ์ ์ฃผ์
์ผ๋ก ์ด๋ฏธ ๋ช
์๋ฅผ ํด๋์๋๋ฐ, ๊ฐ์ฒด ์์ฑ์ ํ๋ฒ ๋ ํ์ ์ด์ ๊ฐ ๊ถ๊ธํด์!
InputView์ OutputView๋ static์ผ๋ก ํธ์ถํ๊ณ ์๋์ฒ๋ผ ํ์๋ฉด ์ด๋จ๊น์??
```suggestion
StoreController storeController = new StoreController(new MemberShipCalculator(), new PromotionCalculateService());
``` |
@@ -0,0 +1,79 @@
+package store.domain;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map.Entry;
+import store.domain.vo.MemberShip;
+import store.domain.vo.ProductQuantity;
+import store.view.dto.response.BuyProductResponse;
+import store.view.dto.response.Free... | Java | ๋ฉ์๋๋ช
์ด ๋ชจ๋ ์ง๊ด์ ์ด์ด์ ์ข๋ค์๐ |
@@ -0,0 +1,54 @@
+package store.domain;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import store.domain.exception.ProductErrorCode;
+import store.domain.exception.ProductException;
+
+public class FileReader {
+
+ ... | Java | List<List<String>>์ผ๋ก ๊ตฌํํ์ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค! |
@@ -0,0 +1,45 @@
+package store.domain;
+
+import store.domain.exception.ProductErrorCode;
+import store.domain.exception.ProductException;
+
+public enum ProductInfo {
+
+ COKE("์ฝ๋ผ", "1000"),
+ CIDER("์ฌ์ด๋ค", "1000"),
+ ORANGE_JUICE("์ค๋ ์ง์ฃผ์ค", "1800"),
+ SPARKLING_WATER("ํ์ฐ์", "1200"),
+ WATER("๋ฌผ", "500"),
... | Java | ํด๋น ๋ถ๋ถ์ ํ์ผ ๋ด์ ์๋ ๋ด์ฉ์ ํ์ฉํด์ ๊ตฌํํด์ผํ์ง ์๋์ฉ?? ๋ฐ๋ก ๋ช
์ํด๋์ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค! |
@@ -0,0 +1,76 @@
+package store.view;
+
+import java.util.List;
+import store.view.dto.response.BuyProductResponse;
+import store.view.dto.response.ErrorResponse;
+import store.view.dto.response.FreeProductResponse;
+import store.view.dto.response.ProductCalculateResponse;
+
+public class OutputView {
+
+ private st... | Java | System.lineSeparator()๋ฅผ ํ์ฉํ ์ ์๊ตฐ์!! ๋ฐฐ์๊ฐ๋๋ค:) |
@@ -0,0 +1,6 @@
+package store.view.dto.request;
+
+public record MemberShipRequest(
+ boolean isMemberShip
+) {
+} | Java | ๋ถ๋ณ์์ ๋ช
์ํ ์ ์๋ record ์ฌ์ฉ ์ข๋ค์!!๐ |
@@ -0,0 +1,63 @@
+package store.domain;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import store.domain.exception.ProductErrorCode;
+import store.domain.exception.ProductException;
+
+... | Java | parse ํด๋์ค๋ domain๋ณด๋ค util ํจํค์ง ๋ด์ ์๋๊ฒ ์ ํฉํ๋ค๊ณ ์๊ฐํ๋๋ฐ, ์ํ๋์ ์๊ฒฌ์ ์ด๋ ์ ๊ฐ์? |
@@ -0,0 +1,54 @@
+package store.domain;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import store.domain.exception.ProductErrorCode;
+import store.domain.exception.ProductException;
+
+public class FileReader {
+
+ ... | Java | FileReader๋ util ํจํค์ง ๋ด์ ์๋๊ฒ ์ ํฉํ๋ค๊ณ ์๊ฐํฉ๋๋ค! |
@@ -0,0 +1,86 @@
+package store.domain;
+
+import java.util.Objects;
+import store.domain.vo.ProductName;
+import store.domain.vo.ProductPrice;
+import store.domain.vo.ProductQuantity;
+
+public class Product {
+
+ private final ProductName name;
+ private final ProductPrice price;
+ private final ProductQuant... | Java | ๋๋ฉ์ธ ํจํค์ง ๋ด์ ํด๋์ค๊ฐ ๋ง์ ๊ฒ ๊ฐ์์!
product์ promotion ๋ฑ์ ํจํค์ง๋ฅผ ํ๋ฒ ๋ ๋ง๋ค์ด์ ๋ถ๋ฆฌํด์ฃผ์๋ฉด ๋๋ฉ์ธ์ ์ญํ ์ด ๋ช
ํํ ๋ณด์ผ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,63 @@
+package store.domain;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import store.domain.exception.ProductErrorCode;
+import store.domain.exception.ProductException;
+
+... | Java | private ๋ฉ์๋๋ก ๋ฉ์๋๋ฅผ ๋ถ๋ฆฌํ๋ ๊ฒ์ ์ด๋จ๊น์? |
@@ -0,0 +1,56 @@
+package store.domain;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import store.domain.exception.ProductErrorCode;
+import store.domain.exception.ProductException;
+
+public class BuyProducts {
+
+ private... | Java | ๋ฐํํด์ค๋ ๋ฐ์ดํฐ์ ์์ ์ฑ์ ์งํค๊ธฐ ์ํด ์ฌ์ฉํ์
จ๊ตฐ์ ๋ฐฐ์๊ฐ๋๋ค |
@@ -0,0 +1,56 @@
+package store.domain;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import store.domain.exception.ProductErrorCode;
+import store.domain.exception.ProductException;
+
+public class BuyProducts {
+
+ private... | Java | ์ ๋ entry๋ฅผ ์ฝํ
๋ฅผ ๋ณผ ๋ ๋ณ๋์ ํด๋์ค ์์ฑ์ด ํ์์๊ณ ํธํด ๋ง์ด ์ฌ์ฉํ๋๋ฐ ์ด๋ ๊ฐ๋
์ฑ ๋ฉด์์ ๋ง์ด ๋จ์ด์ง๋ค๊ณ ๋๋๋๋ค ์ด๋ณด๋ค๋ ๋ฐ๋ก DTO๋ฅผ ๋ง๋๋๊ฒ ๋์๊ฒ ๊ฐ์ต๋๋ค |
@@ -0,0 +1,56 @@
+package store.domain;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import store.domain.exception.ProductErrorCode;
+import store.domain.exception.ProductException;
+
+public class BuyProducts {
+
+ private... | Java | ๋จ์ํ getProductsํ contains๋ฅผ ์ง์ ์ ์ผ๋ก ํ๊ธฐ๋ณด๋จ Products์ public ๋ฉ์๋๋ฅผ ๋ฐ๋ก ๋๋ ๊ฒ์ ์ด๋ค๊ฐ์? |
@@ -0,0 +1,79 @@
+package store.domain;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map.Entry;
+import store.domain.vo.MemberShip;
+import store.domain.vo.ProductQuantity;
+import store.view.dto.response.BuyProductResponse;
+import store.view.dto.response.Free... | Java | ์ํธ๋ฆฌ๋ฅผ ์ง์ ์ ์ผ๋ก ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ฝ๋์ ๊ฐ๋
์ฑ์ด ๋จ์ด์ง๋ค๊ณ ์๊ฐํฉ๋๋ค. getKey(), getValue()๊ณผ ๊ฐ์ด ํค์ ๊ฐ์ผ๋ก ๋ํ๋ด๋ ๋ฉ์๋๋ ์ฝ๋๋ฅผ ์ฝ๋ ์ฌ๋์๊ฒ key๋ ๋ฌด์์ด์ง๋ถํฐ ์์ํ๊ฒ ๋์ด ๋ฐ๋ก ๋ง๋๋๊ฒ ์ข์๊ฒ๊ฐ์ต๋๋ค |
@@ -0,0 +1,78 @@
+import {
+ ChampagnePromotionAvailable,
+ receivedD_dayPromotion,
+ toTalPriceLogic,
+} from "../src/DomainLogic";
+import menuAndQuantity from "../src/utils/menuAndQuantity";
+
+jest.mock("../src/InputView", () => ({
+ christmasInstance: {
+ getMenus: jest.fn(),
+ getDate: jest.fn(),
+ },
... | JavaScript | ๊ฐ ํ
์คํธ์ผ์ด์ค๋ง๋ค ์ธ์คํด์ค๋ฅผ ์์ฑํ๋ ์์ด ์๋ mock์ผ๋ก ์ฌ์ฉํ์ ์ด์ ๊ฐ ์์๊น์? |
@@ -1,5 +1,29 @@
+import { MissionUtils } from "@woowacourse/mission-utils";
+import InputView from "./InputView.js";
+import OutputView from "./OutputView.js";
+
class App {
- async run() {}
+ async run() {
+ await christmasPromotionProcess();
+ }
+}
+
+async function christmasPromotionProcess() {
+ try {
+ ... | JavaScript | ๊ฒฐ๊ณผ ์ถ๋ ฅ์ ๋ฐ๋ผ ๋ค์ ๋ฉ์๋๋ก ๋ฌถ์ด์ ๊ฐ๊ฒฐํ๊ฒ ๋ณด์ฌ์ฃผ๋ ๊ฑด ์ด๋จ๊น์?
์๋ฅผ ๋ค๋ฉด ํ์ฌ Menu๋ถํฐ Badge๊น์ง ํญ๋ชฉ๋ค์ ๋ค ๊ฒฐ๊ณผ์ถ๋ ฅ์ ํด๋น๋๋๊น printResult () ๊ฐ์ด ๋ฉ์๋๋ฅผ ํ๋ ๋ง๋ค๊ณ ๊ทธ ์์์ ์ ๋ถ ๋ค ํธ์ถํ๋ ์์ผ๋ก ๊ฐ ์ธ๋ถ์ฌํญ์ ์จ๊ธฐ๋ฉด ๋ ์ฝ๊ธฐ ํธํ ๊ฑฐ ๊ฐ์์ |
@@ -0,0 +1,86 @@
+class ChristmasPromotion {
+ #date;
+ #menus;
+
+ constructor(date, menus) {
+ this.#date = date;
+ this.#menus = menus;
+ }
+
+ #dateValidate(date) {
+ if (!(date >= 1 && date <= 31)) {
+ throw new Error("[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.");
+ }
+ }
+
+ startDateValidate(date... | JavaScript | ์กฐ๊ฑด์ ๋ณด๋ฉด 1์์ 31๊น์ง์ ์๋ง ํ์ฉํ๋ค๋ ๊ฑด ์์ง๋ง ์ฒ์ ์ฝ๋ ์
์ฅ์์ ์ ๊ทธ ์ฌ์ด์ ์๋ง ํ์ฉ๋๋ ์ง ๋ฐ๋ก ์บ์นํ๊ธฐ๋ ์ด๋ ค์ธ ์๋ ์์ต๋๋ค.
์ด๋ฐ ๋ถ๋ถ ๋๋ฌธ์ ๋งค์ง๋๋ฒ๋ฅผ ์ ๊ฑฐํ๊ณ , ๋ณ์๋ช
์ ์ ๊ฒฝ์ ์จ์ผ ํ๋ ๋ฏ ํด์. ์ง๋ ์ฃผ์ฐจ์ ์ด ๋ถ๋ถ์ ๋ํด ์ ๋ ์ง์งํ๊ฒ ์๊ฐํ๊ณ ์์๊ณ , ์๋์ ๊ฐ์ด ๋ณ๊ฒฝํด ๋ณด์๋๋ฐ ์ด๋ฐ ์์ผ๋ก ์ ๋ชฉํด ๋ณด์๋ ๊ฑด ์ด๋จ๊น์?
```js
dayValidCheck (date) {
const date = new Date('2023-12-${date}').getDate()
if (Number.isNaN(date)) return... |
@@ -0,0 +1,86 @@
+class ChristmasPromotion {
+ #date;
+ #menus;
+
+ constructor(date, menus) {
+ this.#date = date;
+ this.#menus = menus;
+ }
+
+ #dateValidate(date) {
+ if (!(date >= 1 && date <= 31)) {
+ throw new Error("[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.");
+ }
+ }
+
+ startDateValidate(date... | JavaScript | ์ ๊ทํํ์์ ๋ณ์์ ๋ด์์ฃผ๋ฉด ๋ ์ฝ๊ฒ ์ดํดํ ์ ์์ ๊ฑฐ ๊ฐ์์.
์๋ฅผ ๋ค๋ฉด
```js
const MenuFormat = !/^(.+)-(.+)$/
'''
'''
for (const menu of menus) {
if (MenuFormat.test(menu)) {
'''
'''
```
์ด๋ฐ ์์ผ๋ก ๊ฐ๊ธ์ ์ฝ์ ์ ์๋ ๋ฌธ์๋ก ๋ณ๊ฒฝํด์ฃผ๋ฉด ๋ ์ข์ ๋ฏ ํฉ๋๋ค |
@@ -0,0 +1,86 @@
+class ChristmasPromotion {
+ #date;
+ #menus;
+
+ constructor(date, menus) {
+ this.#date = date;
+ this.#menus = menus;
+ }
+
+ #dateValidate(date) {
+ if (!(date >= 1 && date <= 31)) {
+ throw new Error("[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.");
+ }
+ }
+
+ startDateValidate(date... | JavaScript | includes๋ ์ฐพ๋ ์ฒซ๋ฒ์งธ ์์๋ฅผ ๋ฐฐ์ด ์ ์ฒด๋ฅผ ์ํํ๋ฉฐ ์ฐพ์์ ๋ฐํํฉ๋๋ค. ๋ฐ๋ผ์ ๊ท๋ชจ๊ฐ ์ปค์ง๋ฉด ๋นํจ์จ์ ์ผ ์๋ ์์ต๋๋ค.
find๋ ์ฐพ์ผ๋ ค๋ ์ฒซ๋ฒ์งธ ์์๋ฅผ ์ฐพ์ผ๋ฉด true๋ฅผ ๋ฐํํ๊ณ ์ข
๋ฃ๋ฉ๋๋ค. ์ ๋ ๊ทธ๋์ find๋ฅผ ์ ์ฉํ๋ ๋ฐ ๊ทธ ๋ฐ์๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ๋ค๋ ์์ผ๋ ์ฌ๋ฌ ๋ฐฉ๋ฉด์ผ๋ก ์๊ฐํด ๋ณด์
๋ ์ข์ ๋ฏ ํฉ๋๋ค |
@@ -0,0 +1,174 @@
+import { christmasInstance } from "./InputView.js";
+import menuAndQuantity from "./utils/menuAndQuantity.js";
+
+const MENUS_PRICE = {
+ ์์ก์ด์ํ: 6000,
+ ํํ์ค: 5500,
+ ์์ ์๋ฌ๋: 8000,
+ ํฐ๋ณธ์คํ
์ดํฌ: 55000,
+ ๋ฐ๋นํ๋ฆฝ: 54000,
+ ํด์ฐ๋ฌผํ์คํ: 35000,
+ ํฌ๋ฆฌ์ค๋ง์คํ์คํ: 25000,
+ ์ด์ฝ์ผ์ดํฌ: 15000,
+ ์์ด์คํฌ๋ฆผ: 5000,
+ ์ ๋ก์ฝ๋ผ: 3000,... | JavaScript | new Date ์์ฑ ๊ฐ์ฒด์ getDay ๋ฉ์๋๋ฅผ ํ์ฉํด์ ์ฃผ๋ง, ํ์ผ์ ์ฒดํฌํ ์ ์์ต๋๋ค. ํ๋์ฝ๋ฉ ๋ณด๋ค๋ ์ด ๋ฐฉ์์ ์ฌ์ฉํด๋ณด์๊ธธ ์ถ์ฒ๋๋ ค์ |
@@ -0,0 +1,174 @@
+import { christmasInstance } from "./InputView.js";
+import menuAndQuantity from "./utils/menuAndQuantity.js";
+
+const MENUS_PRICE = {
+ ์์ก์ด์ํ: 6000,
+ ํํ์ค: 5500,
+ ์์ ์๋ฌ๋: 8000,
+ ํฐ๋ณธ์คํ
์ดํฌ: 55000,
+ ๋ฐ๋นํ๋ฆฝ: 54000,
+ ํด์ฐ๋ฌผํ์คํ: 35000,
+ ํฌ๋ฆฌ์ค๋ง์คํ์คํ: 25000,
+ ์ด์ฝ์ผ์ดํฌ: 15000,
+ ์์ด์คํฌ๋ฆผ: 5000,
+ ์ ๋ก์ฝ๋ผ: 3000,... | JavaScript | reduce๋ฅผ ์ฌ์ฉํ๋ฉด ๊ตณ์ด ์กฐ๊ฑด๋ฌธ์ ๊ฑธ์ง ์์๋ Menu ๊ฐ๊ฒฉ์ ๊ณ์ฐํ ์ ์์ต๋๋ค.
hasOwnProperty ๋ฉ์๋ ๋ด์์ ์์ฒด์ ์ผ๋ก ํด๋น๊ฐ์ด ์์ ์ 0์ ๋ฐํํ๋๋ก ์ค์ ํ๋ค๋ฉด
์๋ reduce ๋ฉ์๋์์ ์ผํญ์ฐ์ฐ์ ๋ถ๋ถ๋ ์ ๊ฑฐํ ์ ์๊ฒ ๋ค์
```js
MENUS.reduce((acc, menu) => {
const { MENU_NAME, QUANTITY } = menuAndQuantity(menu);
return acc + (MENUS_PRICE.hasOwnProperty(MENU_NAME) ? MENUS_PRICE[MENU_NAM... |
@@ -0,0 +1,174 @@
+import { christmasInstance } from "./InputView.js";
+import menuAndQuantity from "./utils/menuAndQuantity.js";
+
+const MENUS_PRICE = {
+ ์์ก์ด์ํ: 6000,
+ ํํ์ค: 5500,
+ ์์ ์๋ฌ๋: 8000,
+ ํฐ๋ณธ์คํ
์ดํฌ: 55000,
+ ๋ฐ๋นํ๋ฆฝ: 54000,
+ ํด์ฐ๋ฌผํ์คํ: 35000,
+ ํฌ๋ฆฌ์ค๋ง์คํ์คํ: 25000,
+ ์ด์ฝ์ผ์ดํฌ: 15000,
+ ์์ด์คํฌ๋ฆผ: 5000,
+ ์ ๋ก์ฝ๋ผ: 3000,... | JavaScript | ์
๋ ฅํ ๋ ์ง๋งํผ 100์์ฉ ์ถ๊ฐ๋ก ๋ง์ด๋์ค ๊ฐ๊ฒฉ์ ํฉ์ฐํ์ฌ ์ต์ข
ํฉ์ฐ ํ ์ธ๊ธ์ก์ ๊ณ์ฐ์ฒ๋ฆฌํ๊ณ ์์ต๋๋ค.
for๋ฌธ์ ์ฌ์ฉํ์ง ์๊ณ ๋ ์
๋ ฅ ๋ ์ง๋ฅผ ์ด์ฉํด์ ์์์ผ๋ก ํด๋น ์ผ์์ ์ ์ฉํ ์ธ ๊ธ์ก์ ๊ณ์ฐํ ์ ์์ต๋๋ค. ๊ณ ๋ฏผํด๋ณด์๊ณ ์์์ ํ์ฉํด ๋ณด์๋ฉด ์ข์ ๊ฑฐ ๊ฐ์์ (๊ฐ๋จํ ์์๋ค์ ์๊ณ ์์ผ๋ฉด ์๊ฐ๋ณด๋ค ์ฝ๋์์ฑ์ ์์ํ๊ฒ ๋์์ค๋๋ค)
๊ทธ๋ฆฌ๊ณ ๊ฐ๊ธ์ for๋ฌธ์ ์์ฐ๊ณ ํด๊ฒฐํด๋ณด๋ ค๊ณ ํด๋ณด์ธ์. ์ ๋ ์ด ๋ฐฉ์์ผ๋ก ์ฝ๋๋ฅผ ๋ง๋ค๋ค๋ณด๋ ์๋ก์ด ๋ฐฉ๋ฒ๋ค์ ์๊พธ ์ฐพ๊ฒ๋๊ณ ๊ทธ ์์์ ๋ฐฐ์ฐ๋ ๊ฒ๋ค์ด ์ ๋ง ๋ง๋๋ผ๊ณ ์ |
@@ -0,0 +1,174 @@
+import { christmasInstance } from "./InputView.js";
+import menuAndQuantity from "./utils/menuAndQuantity.js";
+
+const MENUS_PRICE = {
+ ์์ก์ด์ํ: 6000,
+ ํํ์ค: 5500,
+ ์์ ์๋ฌ๋: 8000,
+ ํฐ๋ณธ์คํ
์ดํฌ: 55000,
+ ๋ฐ๋นํ๋ฆฝ: 54000,
+ ํด์ฐ๋ฌผํ์คํ: 35000,
+ ํฌ๋ฆฌ์ค๋ง์คํ์คํ: 25000,
+ ์ด์ฝ์ผ์ดํฌ: 15000,
+ ์์ด์คํฌ๋ฆผ: 5000,
+ ์ ๋ก์ฝ๋ผ: 3000,... | JavaScript | ์ํฉ๋ง๋ค ๋ค๋ฅด์ง๋ง ์์ ์์๋ฅผ ๋ถ์ฌ์ ์์๋ก ๋ง๋ค ๋ ์ง๊ด์ ์ด๊ณ ๋ช
ํํ ํํํ๊ธฐ ์ํด ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๋ฉด ๋ ํธํ ์ ์์ต๋๋ค.
๊ทธ๋ฆฌ๊ณ else if์ ๋์ด๋๋ ์กฐ๊ฑด๋ฌธ์ด ๊ธธ์ด์ง ์๋ก ๊ฐ๋
์ฑ์ ํด์น๊ธฐ์ ์ง์ํ๋ ํธ์ด ์ข๋ค๊ณ ํฉ๋๋ค.
์๋์ฒ๋ผ ์์ ํด๋ณด์๋ ๊ฑด ์ด๋จ๊น์?
```js
const TOTAL_AFTER = Math.abs(receivedTotalBenefitPrice())
if (TOTAL_AFTER >= 20000) return "์ฐํ";
if (TOTAL_AFTER >= 10000) return "ํธ๋ฆฌ";
if... |
@@ -0,0 +1,86 @@
+class ChristmasPromotion {
+ #date;
+ #menus;
+
+ constructor(date, menus) {
+ this.#date = date;
+ this.#menus = menus;
+ }
+
+ #dateValidate(date) {
+ if (!(date >= 1 && date <= 31)) {
+ throw new Error("[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.");
+ }
+ }
+
+ startDateValidate(date... | JavaScript | for..of๋ javascript airbnb์์ ์ถ์ฒํ์ง ์๋ ๋ฐฉ๋ฒ์ด๋ผ๊ณ ํฉ๋๋ค !
forEach()๋ map()์ ์จ๋ณด์๋๊ฑด ์ด๋จ๊น์?
ํด๋น ํจ์๋ for..of์ if๋ฌธ์ ์ฌ์ฉํ๋๊ฑฐ๋ `filter()`๊ฐ ์ ํฉํด๋ณด์
๋๋ค !
์ฐธ๊ณ : [Javascript Airbnb 11.1](https://github.com/tipjs/javascript-style-guide#11.1) |
@@ -0,0 +1,86 @@
+class ChristmasPromotion {
+ #date;
+ #menus;
+
+ constructor(date, menus) {
+ this.#date = date;
+ this.#menus = menus;
+ }
+
+ #dateValidate(date) {
+ if (!(date >= 1 && date <= 31)) {
+ throw new Error("[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.");
+ }
+ }
+
+ startDateValidate(date... | JavaScript | has๋ฅผ ์ฌ์ฉํ๋ฉด ๋ํ
์ผํ๊ฒ ์ค๋ณต ์ฒ๋ฆฌํ ์ ์๊ตฐ์...!
์ ๋ ๋ฉ๋ด๋ฅผ ๋ถ๋ฆฌํด์ setํจ์๋ฅผ ์ฌ์ฉํ์๋๋ฐ ์ด๋ฐ ๋ฐฉ๋ฒ๋ ์๋ค๋ ๊ฒ์ ๋ฐฐ์๊ฐ๋๋ค !! |
@@ -0,0 +1,174 @@
+import { christmasInstance } from "./InputView.js";
+import menuAndQuantity from "./utils/menuAndQuantity.js";
+
+const MENUS_PRICE = {
+ ์์ก์ด์ํ: 6000,
+ ํํ์ค: 5500,
+ ์์ ์๋ฌ๋: 8000,
+ ํฐ๋ณธ์คํ
์ดํฌ: 55000,
+ ๋ฐ๋นํ๋ฆฝ: 54000,
+ ํด์ฐ๋ฌผํ์คํ: 35000,
+ ํฌ๋ฆฌ์ค๋ง์คํ์คํ: 25000,
+ ์ด์ฝ์ผ์ดํฌ: 15000,
+ ์์ด์คํฌ๋ฆผ: 5000,
+ ์ ๋ก์ฝ๋ผ: 3000,... | JavaScript | ์๋๋ฉด ๊ฐ์ฒด๋ก ์ ์ธํ์ ๋ค์์ find๋ฅผ ์ฌ์ฉํ๋ ๊ฒ๋ ๊ด์ฐฎ์ ๊ฒ ๊ฐ์ต๋๋ค!
๊ธ์ก ์กฐ๊ฑด์ด 3๊ฐ๋๊น ๊ด์ฐฎ์ ๋ณด์
๋๋ค ! |
@@ -1,7 +1,27 @@
-export default InputView = {
- async readDate() {
- const input = await Console.readLineAsync("12์ ์ค ์๋น ์์ ๋ฐฉ๋ฌธ ๋ ์ง๋ ์ธ์ ์ธ๊ฐ์? (์ซ์๋ง ์
๋ ฅํด ์ฃผ์ธ์!)");
- // ...
- }
- // ...
-}
+import { MissionUtils } from "@woowacourse/mission-utils";
+import ChristmasDomain from "./ChristmasPromotion.js";... | JavaScript | ํด๋น ๋ฌธ๊ตฌ๋ ๋ณํ์ง ์๋ ์์๊ฐ์ด๋ ๋ณํ์ง ์์ ์์๊ฐ๋ค์ ๋ฐ๋ก constant๋ฅผ ๋ง๋ค์ด์ ํ ๋ฒ์ ์ ๋ฆฌํ๋ ๊ฒ๋ ๊ด์ฐฎ์ ๊ฒ ๊ฐ์ต๋๋ค ! |
@@ -1,7 +1,27 @@
-export default InputView = {
- async readDate() {
- const input = await Console.readLineAsync("12์ ์ค ์๋น ์์ ๋ฐฉ๋ฌธ ๋ ์ง๋ ์ธ์ ์ธ๊ฐ์? (์ซ์๋ง ์
๋ ฅํด ์ฃผ์ธ์!)");
- // ...
- }
- // ...
-}
+import { MissionUtils } from "@woowacourse/mission-utils";
+import ChristmasDomain from "./ChristmasPromotion.js";... | JavaScript | ํด๋น ๋ฏธ์
์ ์ฐํ
์ฝ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ Random์ ์ฌ์ฉํ์ง ์์ผ๋ `Console`๋ก๋ง ์ ์ธํ์๋ฉด ์ฝ๋๊ฐ ์กฐ๊ธ ๋ ๊น๋ํด ์ง ๊ฒ ๊ฐ์์ ! |
@@ -0,0 +1,24 @@
+import menuAndQuantity from "./utils/menuAndQuantity.js";
+
+class Order {
+ #order;
+
+ constructor(order) {
+ this.#order = Array.isArray(order) ? order : [order];
+ this.#orderQuantityValidate();
+ }
+
+ #orderQuantityValidate() {
+ this.#order.forEach((menu) => {
+ const { QUANTI... | JavaScript | forEach()๋ก ์ ์ธํ์ ์ด์ ๋ฅผ ์ ์ ์์๊น์?? |
@@ -1,7 +1,110 @@
-export default OutputView = {
- printMenu() {
- Console.print("<์ฃผ๋ฌธ ๋ฉ๋ด>");
- // ...
+import { MissionUtils } from "@woowacourse/mission-utils";
+import { christmasInstance } from "./InputView.js";
+import {
+ ChampagnePromotionAvailable,
+ receivedChampagnePromotion,
+ receivedD_da... | JavaScript | ํด๋น ํํ ๋ด์ญ์ ๋ฐฐ์ด๋ก ์
๋ ฅ๋ฐ์์ forEach()ํจ์๋ฅผ ์จ์ ์ถ๋ ฅํ๋ฉด ์กฐ๊ธ ๋ ๊น๋ํ ๊ฒ ๊ฐ์ต๋๋ค !
0์์ด๊ฑฐ๋ ํด๋นํ์ง ์์ผ๋ฉด undefined๋ก ์
๋ ฅ๋ฐ๊ณ filter()๋ก ์ ๊ฑฐํ๋ฉด ์ฝ๋ ๊ธธ์ด๊ฐ ํ ์ค์ด๋ค ๊ฒ ๊ฐ์ต๋๋ค ! |
@@ -1,5 +1,29 @@
+import { MissionUtils } from "@woowacourse/mission-utils";
+import InputView from "./InputView.js";
+import OutputView from "./OutputView.js";
+
class App {
- async run() {}
+ async run() {
+ await christmasPromotionProcess();
+ }
+}
+
+async function christmasPromotionProcess() {
+ try {
+ ... | JavaScript | ํธ์ถ ๋ฉ์๋๊ฐ ๋ง์ ๊ธธ์ด์ง ๊ฑธ ์ ๋ฆฌํ์ง ์์์๋๋ฐ printResult () ๋ฉ์๋๋ฅผ ์์ฑํ๋ ๋ฐฉ์ ์ข์์! |
@@ -0,0 +1,86 @@
+class ChristmasPromotion {
+ #date;
+ #menus;
+
+ constructor(date, menus) {
+ this.#date = date;
+ this.#menus = menus;
+ }
+
+ #dateValidate(date) {
+ if (!(date >= 1 && date <= 31)) {
+ throw new Error("[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.");
+ }
+ }
+
+ startDateValidate(date... | JavaScript | ์ง๊ธ๊น์ง ์์๋ผ๋ ๊ฐ๋
์ ์์์ง๋ง ์์๋ฅผ ์ ์ฌ์ฉํ๋์ง์ ๊ณ ๋ฏผ์ด ์์๋ ๊ฒ ๊ฐ์์. ๐ฅฒ๐ |
@@ -0,0 +1,86 @@
+class ChristmasPromotion {
+ #date;
+ #menus;
+
+ constructor(date, menus) {
+ this.#date = date;
+ this.#menus = menus;
+ }
+
+ #dateValidate(date) {
+ if (!(date >= 1 && date <= 31)) {
+ throw new Error("[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.");
+ }
+ }
+
+ startDateValidate(date... | JavaScript | ๋ฌด์์ ํด๊ฒฐํด๋ณด๊ณ ๋ณธ๋ค ์คํ์ผ์ด์๋๋ฐ, ์ ๋ง ํด๊ฒฐํ๊ณ ๋์ด์๋ค์. ์์ฑํ ๋๋ถํฐ ์ํฉ์ ๋ง๋ ํจ์จ์ ์ธ ๋ฉ์๋๋ฅผ ํํ๋ ๊ฒ์ด ์ข๊ฒ ์ง๋ง, ํ๊ณ ๋์ ํ์ธํ์ ๋ '์ฌ๊ธฐ์ ๋ง๋ ๋ ์ข์ ๋ฉ์๋๊ฐ ์๋?' ๊ณ ๋ฏผํด ๋ด์ผ๊ฒ ์ด์! |
@@ -0,0 +1,86 @@
+class ChristmasPromotion {
+ #date;
+ #menus;
+
+ constructor(date, menus) {
+ this.#date = date;
+ this.#menus = menus;
+ }
+
+ #dateValidate(date) {
+ if (!(date >= 1 && date <= 31)) {
+ throw new Error("[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.");
+ }
+ }
+
+ startDateValidate(date... | JavaScript | ๋งค์ง๋๋ฒ๋ฅผ ์ ๊ฐ ์ฌ์ฉํ๋ ๊ฑฐ๊ตฐ์! ์๋ฏธ์๊ฒ ์ฝ๋ ๊ธธ์ด๊ฐ ๊ธธ์ด์ง ๊ฒ ๊ฐ์์.
๋, ์์ฑ์ ํจ์ ์ฌ์ฉ(๊ฐ์ฒด...!)์ ์ ๊ทน์ ์ผ๋ก ์์ผ๋ก ์ฌ์ฉํด์ผ ๊ฒ ์ด์. |
@@ -0,0 +1,174 @@
+import { christmasInstance } from "./InputView.js";
+import menuAndQuantity from "./utils/menuAndQuantity.js";
+
+const MENUS_PRICE = {
+ ์์ก์ด์ํ: 6000,
+ ํํ์ค: 5500,
+ ์์ ์๋ฌ๋: 8000,
+ ํฐ๋ณธ์คํ
์ดํฌ: 55000,
+ ๋ฐ๋นํ๋ฆฝ: 54000,
+ ํด์ฐ๋ฌผํ์คํ: 35000,
+ ํฌ๋ฆฌ์ค๋ง์คํ์คํ: 25000,
+ ์ด์ฝ์ผ์ดํฌ: 15000,
+ ์์ด์คํฌ๋ฆผ: 5000,
+ ์ ๋ก์ฝ๋ผ: 3000,... | JavaScript | ์ ๊ฐ ํ๋์ฝ๋ฉ์ ์ ๋๋ก ํ๋ค์.
```js
let weekday = true;
const date = new Date(`2023-12-${์ ์ฅ๋ ๊ฐ}`);
if (date.getDay() === 5 || date.getDay() === 6) {
weekday = false;
} else {
weekday = true;
}
```
์ด๋ฐ ์์ผ๋ก ์๊ฐ์ ๋ฐ๊ฟ๋ณผ๊ฒ์! |
@@ -0,0 +1,174 @@
+import { christmasInstance } from "./InputView.js";
+import menuAndQuantity from "./utils/menuAndQuantity.js";
+
+const MENUS_PRICE = {
+ ์์ก์ด์ํ: 6000,
+ ํํ์ค: 5500,
+ ์์ ์๋ฌ๋: 8000,
+ ํฐ๋ณธ์คํ
์ดํฌ: 55000,
+ ๋ฐ๋นํ๋ฆฝ: 54000,
+ ํด์ฐ๋ฌผํ์คํ: 35000,
+ ํฌ๋ฆฌ์ค๋ง์คํ์คํ: 25000,
+ ์ด์ฝ์ผ์ดํฌ: 15000,
+ ์์ด์คํฌ๋ฆผ: 5000,
+ ์ ๋ก์ฝ๋ผ: 3000,... | JavaScript | `forEach`์ `if๋ฌธ`์ ์ฌ์ฉํ์ง ์๊ณ ๋ Menu ๊ฐ๊ฒฉ์ ๊ณ์ฐํ ์ ์๋ค์! |
@@ -0,0 +1,174 @@
+import { christmasInstance } from "./InputView.js";
+import menuAndQuantity from "./utils/menuAndQuantity.js";
+
+const MENUS_PRICE = {
+ ์์ก์ด์ํ: 6000,
+ ํํ์ค: 5500,
+ ์์ ์๋ฌ๋: 8000,
+ ํฐ๋ณธ์คํ
์ดํฌ: 55000,
+ ๋ฐ๋นํ๋ฆฝ: 54000,
+ ํด์ฐ๋ฌผํ์คํ: 35000,
+ ํฌ๋ฆฌ์ค๋ง์คํ์คํ: 25000,
+ ์ด์ฝ์ผ์ดํฌ: 15000,
+ ์์ด์คํฌ๋ฆผ: 5000,
+ ์ ๋ก์ฝ๋ผ: 3000,... | JavaScript | ```js
if (available) {
minusPrice += (DATE -1) * 100;
} else {
minusPrice = 0;
}
```
Songhynseop ๋ฆฌ๋ทฐ๋ก ์๋ ค์ฃผ์ ๊ฒ์ ๋ณด๊ณ ๊ณ ์ณ๋ณด์์ด์. ์์์ผ๋ก ๊ฐ๋จํ๊ฒ ํด๊ฒฐํ ์ ์๋ค์.
'ํน์ ๋ฌธ๋ฒ์ ์ฌ์ฉํ ๋ ๊ผญ ํ์ํ ๊ฐ? ๋ ๊ฐ๋จํ๊ฒ ํ ์ ์๋' ์๊ฐํด ๋ณผ๊ฒ์! |
@@ -0,0 +1,174 @@
+import { christmasInstance } from "./InputView.js";
+import menuAndQuantity from "./utils/menuAndQuantity.js";
+
+const MENUS_PRICE = {
+ ์์ก์ด์ํ: 6000,
+ ํํ์ค: 5500,
+ ์์ ์๋ฌ๋: 8000,
+ ํฐ๋ณธ์คํ
์ดํฌ: 55000,
+ ๋ฐ๋นํ๋ฆฝ: 54000,
+ ํด์ฐ๋ฌผํ์คํ: 35000,
+ ํฌ๋ฆฌ์ค๋ง์คํ์คํ: 25000,
+ ์ด์ฝ์ผ์ดํฌ: 15000,
+ ์์ด์คํฌ๋ฆผ: 5000,
+ ์ ๋ก์ฝ๋ผ: 3000,... | JavaScript | Songhyunseop ๋๋ถ์ ์ ๋๊ฐ์ ๋ฐํํด์ฃผ๋ `Math.abs()`์ ์ฌ์ฉ์ ์ ์ ์์์ด์. ์ด๋ฏธ ์ ๊ณตํ๋ ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ๋ ์ข๋ค๊ณ ํผ๋๋ฐฑ์์ ๋ณด์๋๋ฐ ์ด ๋ป์ธ ๊ฒ ๊ฐ์์. else if๋ฌธ ๋์ if์์ return ์ ์ฉ ์์ ๋ณด์ฌ์ฃผ์ ๊ฑฐ ๊ฐ์ฌํด์.
hyurim ๋ฆฌ๋ทฐ์ ๋ฐ๋ฅด๋ฉด ๋ ๊ฐ์ฒด์งํฅ์ ์ผ๋ก ์ฝ๋๋ฅผ ์์ฑํ ์ ์์ด์ ์ข์์.
```JS
const BADGE_THRESHOLDS = { ์ฐํ: 20000, ํธ๋ฆฌ: 10000, ๋ณ: 5000 };
export function sendBadge() {
const TOTAL_AFTER =... |
@@ -0,0 +1,78 @@
+import {
+ ChampagnePromotionAvailable,
+ receivedD_dayPromotion,
+ toTalPriceLogic,
+} from "../src/DomainLogic";
+import menuAndQuantity from "../src/utils/menuAndQuantity";
+
+jest.mock("../src/InputView", () => ({
+ christmasInstance: {
+ getMenus: jest.fn(),
+ getDate: jest.fn(),
+ },
... | JavaScript | christmasInstance๋ฅผ ์ ์ธํ๋ฉด ํจ์๋ผ mock๋ฅผ ์ ์ฉํ๋ ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,86 @@
+class ChristmasPromotion {
+ #date;
+ #menus;
+
+ constructor(date, menus) {
+ this.#date = date;
+ this.#menus = menus;
+ }
+
+ #dateValidate(date) {
+ if (!(date >= 1 && date <= 31)) {
+ throw new Error("[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.");
+ }
+ }
+
+ startDateValidate(date... | JavaScript | ````js
menus.forEach((menu) => { . . .
````
์ด๋ฐ ์์ผ๋ก ์ฝ๋๋ฅผ ๊ณ ์น๊ฒ ์ต๋๋ค. `for..of`๋ ์ฌ์ฉ์ ์ง์ํ๋๋ก ํ๊ฒ ์ต๋๋ค! |
@@ -1,7 +1,27 @@
-export default InputView = {
- async readDate() {
- const input = await Console.readLineAsync("12์ ์ค ์๋น ์์ ๋ฐฉ๋ฌธ ๋ ์ง๋ ์ธ์ ์ธ๊ฐ์? (์ซ์๋ง ์
๋ ฅํด ์ฃผ์ธ์!)");
- // ...
- }
- // ...
-}
+import { MissionUtils } from "@woowacourse/mission-utils";
+import ChristmasDomain from "./ChristmasPromotion.js";... | JavaScript | ์คํธ!
```js
import { Console } from "@woowacourse/mission-utils";
```
import ํด์ค๋ ๊ฒ๋ ์ ์ธํ๋ค๊ณ ํํํ๋ ๊ฒ๋ ์ฒ์ ์์์ด์! ๊ฐ์ฌํฉ๋๋ค. |
@@ -1,7 +1,27 @@
-export default InputView = {
- async readDate() {
- const input = await Console.readLineAsync("12์ ์ค ์๋น ์์ ๋ฐฉ๋ฌธ ๋ ์ง๋ ์ธ์ ์ธ๊ฐ์? (์ซ์๋ง ์
๋ ฅํด ์ฃผ์ธ์!)");
- // ...
- }
- // ...
-}
+import { MissionUtils } from "@woowacourse/mission-utils";
+import ChristmasDomain from "./ChristmasPromotion.js";... | JavaScript | ๋ค ๋ณํ์ง ์๋ ๊ฒ์ ์์๋ก ๋ฐ๊ฟ์ผ ์ข๋ค์. ๊ฐ์ฌํฉ๋๋ค! |
@@ -0,0 +1,24 @@
+import menuAndQuantity from "./utils/menuAndQuantity.js";
+
+class Order {
+ #order;
+
+ constructor(order) {
+ this.#order = Array.isArray(order) ? order : [order];
+ this.#orderQuantityValidate();
+ }
+
+ #orderQuantityValidate() {
+ this.#order.forEach((menu) => {
+ const { QUANTI... | JavaScript | ```js
export default function menuAndQuantity(menu) {
const [MENU_NAME, NUMBER] = menu.split("-");
const QUANTITY = parseInt(NUMBER, 10);
return { MENU_NAME, QUANTITY };
}
```
**์ด `menuAndQuantity(menu)` ํจ์๋ฅผ ์ฌ์ฉํด์ ์๋ ํ์
**ํ์ต๋๋ค.
๊ทธ๋ฌ๊ธฐ ์ํด์๋ menu (menu-quantity)๊ฐ ํ๋์ฉ ์ ๋ฌํด์ผ ํด์ `forEach()`๋ฅผ ์ฌ์ฉํ์ต๋๋ค. |
@@ -1,7 +1,110 @@
-export default OutputView = {
- printMenu() {
- Console.print("<์ฃผ๋ฌธ ๋ฉ๋ด>");
- // ...
+import { MissionUtils } from "@woowacourse/mission-utils";
+import { christmasInstance } from "./InputView.js";
+import {
+ ChampagnePromotionAvailable,
+ receivedChampagnePromotion,
+ receivedD_da... | JavaScript | return ๊ฐ์ด 0, ๊ณตํต๋ถ๋ถ์ ํ์ฉํ๋ฉด ์ ๋ง ๊น๋ํ ์ฝ๋๊ฐ ๋๊ฒ ๋ค์!
๋ฐ๋ก ๊ณ ์น๊ธฐ์๋ ์ข ์ด๋ ค์์ ๋ ์๊ฐํด๋ณด๊ณ ์ฝ๋๋ฅผ ์์ ํด ๋ณด๊ฒ ์ต๋๋ค! ๊ฐ์ฌํฉ๋๋ค! |
@@ -0,0 +1,162 @@
+package store.controller;
+
+import static store.controller.PromotionController.getValidInput;
+
+import java.text.NumberFormat;
+import java.util.List;
+import store.model.Receipt;
+import store.view.InputView;
+import store.view.OutputView;
+import store.view.error.ErrorException;
+import store.vie... | Java | ์ ๊ฐ ์ ๋ฒ์๋ ์ฌ๊ท ํจ์๊ฐ ์์ข์ง ์์๊น๋ผ๋ ์์ผ๋ก ์๊ธฐ๋ฅผ ํ์์ง๋ง ์๋
3์ฃผ์ฐจ ํผ๋๋ฐฑ์ ๋ณด๋ ์ฌ๊ทํจ์๋ก ์ฒ๋ฆฌํ ์ ์๋ค๋ ๋ด์ฉ์ด ์๋๊ตฐ์... ์ฝ๋๋ฅผ ์ค์ผ ์ ์๋ค๋ฉด ์ฌ๊ท๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,162 @@
+package store.controller;
+
+import static store.controller.PromotionController.getValidInput;
+
+import java.text.NumberFormat;
+import java.util.List;
+import store.model.Receipt;
+import store.view.InputView;
+import store.view.OutputView;
+import store.view.error.ErrorException;
+import store.vie... | Java | ์ ๋ ๋ชฐ๋๋ ๋ด์ฉ์ด์ง๋ง String format๊ณผ %-8s(8์นธ๋งํผ ์ผ์ชฝ์ ๋ ฌ ์ด๋ฐ์์ผ๋ก ์ฌ์ฉํด์ ์ ๋ ฌ์ ์๋ํ๋๊ตฐ์ |
@@ -0,0 +1,306 @@
+package store.controller;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import store.model.Product;
+import store.model.ProductStock;
+import store.model.Promotion... | Java | enum์ ์ฌ์ฉํด์ ์ฒ๋ฆฌํ ์ ์๋ ๋ถ๋ถ์
๋๋ค! |
@@ -1,7 +1,26 @@
package store;
+
+import store.controller.FrontController;
+import store.controller.ProductController;
+import store.controller.PromotionController;
+import store.view.InputView;
+import store.view.OutputView;
+
+
public class Application {
+
+
public static void main(String[] args) {
- ... | Java | ํด๋์ค๋ช
์ผ๋ก ์๋ฏธ๋ฅผ ์ ์ ์์ผ๋ฏ๋ก ๋ฉ์๋๋ช
์ ํํ์ํด๋ ๋ ๊ฑฐ ๊ฐ์ต๋๋ค |
@@ -0,0 +1,169 @@
+# 1. ํต์ฌ ํ ์ค ์ ์
+
+์ฌ์ฉ์์ ์ฅ๋ฐ๊ตฌ๋ ์ํ ๋ชฉ๋ก ๋ฐ ์์ ๊ฒฐ์ ๊ธ์ก์ ํ์ธํ๊ณ , ๊ฒฐ์ ๋จ๊ณ๋ก ์ ํํ๋ค.
+
+# 2. ์ฌ์ฉ์ ๊ด์ ์์ ๊ธฐ๋ฅ ๋ฆฌ์คํ
(์ธ๋ถ ๊ธฐ๋ฅ ์ ์)
+
+- [ ] CartItem
+ - [ ] ์ฅ๋ฐ๊ตฌ๋ ์ํ ์ ๋ณด๋ฅผ ๋ณด์ฌ์ค๋ค
+ - [ ] ์ฅ๋ฐ๊ตฌ๋ ์ํ์ ์ ํ/ํด์ ํ๋ค.
+ - [ ] ์ฅ๋ฐ๊ตฌ๋ ์ํ์ ์ ๊ฑฐํ๋ค.
+ - [ ] ์ฅ๋ฐ๊ตฌ๋ ์ํ ์๋์ ๋ณ๊ฒฝํ๋ค.
+- [ ] CartItemList
+ - [ ] ์ฅ๋ฐ๊ตฌ๋ ์ํ ๋ชฉ๋ก์ ๋ณด์ฌ์ค๋ค.
+ - [ ] ์ ์ฒด ์ ํ
+- [ ] CartAmount... | Unknown | ํน์ ์ฒดํฌ๋ฆฌ์คํธ๋ ์ผ๋ถ๋ฌ ์ฒดํฌ ์ํ์ ๊ฑธ๊น์?! ๐ซ |
@@ -0,0 +1,10 @@
+์ผ๊ด์ฑ์ ์ ์งํ๊ธฐ ์ํ ๊ท์น
+
+### recoil
+
+1. ๋ฆฌ๋ ๋๋ฅผ ์ด๋ฐํ๋ ๋ฐ์ดํฐ์ ํด๋นํ๋ ๊ฒฝ์ฐ ์ด๋ฆ์ State๋ฅผ ๋ถ์ธ๋ค.
+ 1. atom์ ๋ฌด์กฐ๊ฑด State๋ฅผ ๋ถ์ธ๋ค.
+ 2. selector๋ ๋ด๋ถ์ ์ผ๋ก ํ๋ ์ด์์ atom์ ์ด์ฉํ๋ ๊ฒฝ์ฐ State๋ฅผ ๋ถ์ธ๋ค.
+2. selector์ ์ฉ๋๋ ์ธ ๊ฐ์ง์ด๋ค.
+ 1. atom ํ์ ์ํ
+ 2. ๋น๋๊ธฐ ๋ฐ์ดํฐ ํจ์นญ | Unknown | ๊ท์น๊น์ง ๋ํ
์ผ.. ๐ |
@@ -1,10 +1,24 @@
import "./App.css";
+import { RecoilRoot } from "recoil";
+import { BrowserRouter, Route, Routes } from "react-router-dom";
+
+import CartPage from "./pages/CartPage";
+import { PATH } from "./constants/path";
+import OrderSummaryPage from "./pages/OrderSummaryPage";
+import { ErrorBoundary } from "r... | Unknown | [crerateBrowserRouter](https://reactrouter.com/en/main/routers/create-browser-router)๋ ์ถํ์ ํ ๋ฒ ์จ๋ณด์๋๊ฑฐ ์ถ์ฒ๋๋ฆฝ๋๋ค :) ๐ซ |
@@ -0,0 +1,31 @@
+import styled from "styled-components";
+
+export interface IButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
+ disabled?: boolean;
+}
+
+export default function Button({ children, ...attributes }: IButtonProps) {
+ return <S.Button {...attributes}>{children}</S.Button>;
+}
+
+const S =... | Unknown | ์คํ์ผ์ ์ํ ๋ฒํผ ์ปดํฌ๋ํธ๋ก ํ์ธ๋๋๋ฐ, ์ด๋ฅผ ํด๋๋ก ๊ตฌ์กฐํ์ํค๋ฉด ๋ฒํผ์ ์ญํ ์ ํ์
ํ๋๋ฐ ๋์ฑ ์ข์ ๊ฒ ๊ฐ์์! ๐ซ |
@@ -0,0 +1,91 @@
+import { useRecoilValue } from "recoil";
+import styled from "styled-components";
+import { deliveryCostState, orderAmountState, totalOrderAmountState } from "../recoil/cartAmount";
+import { ReactComponent as InfoIcon } from "../assets/info-icon.svg";
+
+export interface ICartAmountProps {}
+
+export... | Unknown | ์ฌ์ฉ๋์ง ์๋ Props์ธ๊ฐ์?! ๐ |
@@ -0,0 +1,82 @@
+import { useSetRecoilState } from "recoil";
+import CartItemView from "./CartItemView";
+import styled from "styled-components";
+import { selectedCartItemIdsState } from "../recoil/selectedCartItemIds";
+import { CartItem } from "../types/cartItems";
+import { useCartItemControl } from "../hooks/useC... | Unknown | (๋จ์ ๊ถ๊ธ) cartItem.id๊ฐ ์๋๋ผ product.id๋ก ์ค์ ํด์ฃผ์ ์ด์ ๊ฐ ์์๊น์? |
@@ -0,0 +1,145 @@
+import { CartItem } from "../types/cartItems";
+import styled from "styled-components";
+import { UseCartItemsReturn } from "../hooks/useCartItemControl";
+
+export interface CartItemViewProps {
+ cartItem: CartItem;
+ cartItemControl: UseCartItemsReturn;
+}
+
+export default function CartItemView(... | Unknown | ์ฌ๊ธฐ์ Return interface๋ฅผ ๋ณ๋๋ก export ํด์ค๋ ์ข์ง๋ง,
[ReturnType](https://www.typescriptlang.org/ko/docs/handbook/utility-types.html#returntypetype)์ด๋ผ๋ ์ ํธํจ์๋ ์ฌ์ฉํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์์!
์ด๋ ๊ฒ ์ฌ์ฉํ๋ฉด ๋ณ๋์ interface๋ฅผ ๋ง๋ค ํ์ ์์ง ์์๊น ์๊ฐํฉ๋๋ค! :) |
@@ -0,0 +1,91 @@
+import { RecoilRoot, useRecoilState } from "recoil";
+
+import { act } from "react";
+import { renderHook } from "@testing-library/react";
+import { updateCartItemQuantity } from "../api/cartItems";
+import { useCartItemControl } from "./useCartItemControl";
+
+jest.mock("recoil", () => ({
+ ...jest.... | TypeScript | ์ฌ๊ธฐ ์ฃผ์์ ์ผ๋ถ๋ฌ ๋จ๊ฒจ๋์ ๊ฑธ๊น์?! ๐ซ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.