code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -0,0 +1,8 @@
+import { MissionUtils } from '@woowacourse/mission-utils';
+
+export const readLineAsync = async (query) => {
+ const input = await MissionUtils.Console.readLineAsync(query);
+ return input;
+};
+
+export const print = (message) => MissionUtils.Console.print(message); | JavaScript | ๊ตฌ์กฐ๋ถํด ํ ๋น์ผ๋ก Console๋ก๋ง ์ฒ๋ฆฌํด๋ ๋์ง ์๋์? |
@@ -0,0 +1,104 @@
+import { print } from '../utils/missionUtils.js';
+import {
+ GIFT_THRESHOLD,
+ BENEFITS_THRESHOLD,
+ MENU_PRICE,
+} from '../utils/constants.js';
+
+const OutputView = {
+ printWelcome() {
+ print('์๋
ํ์ธ์! ์ฐํ
์ฝ ์๋น 12์ ์ด๋ฒคํธ ํ๋๋์
๋๋ค.');
+ },
+
+ printGuide(date) {
+ print(`12์ ${date}์ผ์ ์ฐํ
์ฝ ์๋น... | JavaScript | ๋ณ์๋ช
์ ์๋ฃํ์ ๋ฃ๋ ๊ฒ ์ข์ง ์๋ค๊ณ ๋ค์์ด์.
orders์ ๊ฐ์ด ๋ณต์ํํ์ผ๋ก ๋ฐ๊พธ์ด ์ฃผ์๋ฉด ์ข์ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,115 @@
+import OrderMenu from '../domain/OrderMenu.js';
+
+describe('์ฃผ๋ฌธ ๋ฉ๋ด ๊ฒ์ฆ ํ
์คํธ', () => {
+ const orderMenuTestCase = [
+ {
+ testName: '์ฃผ๋ฌธ ํ์์ด ์์์ ๋ค๋ฅด๋ฉด ์์ธ๊ฐ ๋ฐ์ํ๋ค.',
+ input: '์์ก์ด์ํ 1๊ฐ, ์ด์ฝ์ผ์ดํฌ 2๊ฐ',
+ },
+ {
+ testName: '๋ฉ๋ดํ์ ์๋ ๋ฉ๋ด๊ฐ ์์ผ๋ฉด ์์ธ๊ฐ ๋ฐ์ํ๋ค.',
+ input: 'ํฐ๋ณธ์คํ
์ดํฌ-1,๋ง๋ผํ-1',
+ ... | JavaScript | test.each()๋ฅผ ์ฌ์ฉํ์ง ์๊ณ ์ด๋ ๊ฒ ์ฒ๋ฆฌํ์ ์ด์ ๊ฐ ์์ผ์ค๊น์? |
@@ -0,0 +1,126 @@
+import { MENU_PRICE } from '../utils/constants.js';
+
+const MENU_TYPES = Object.freeze({
+ appetizer: ['์์ก์ด์ํ', 'ํํ์ค', '์์ ์๋ฌ๋'],
+ main: ['ํฐ๋ณธ์คํ
์ดํฌ', '๋ฐ๋นํ๋ฆฝ', 'ํด์ฐ๋ฌผํ์คํ', 'ํฌ๋ฆฌ์ค๋ง์คํ์คํ'],
+ dessert: ['์ด์ฝ์ผ์ดํฌ', '์์ด์คํฌ๋ฆผ'],
+ drink: ['์ ๋ก์ฝ๋ผ', '๋ ๋์์ธ', '์ดํ์ธ'],
+});
+
+const LIMIT_NUMBER = Object.freeze({
+ minN... | JavaScript | ์ด ๋ถ๋ถ๋ ์ฌ๊ธฐ์ ๋์ ์ด์ ๊ฐ ๋ฐ๋ก ์์ผ์ ์ง ๊ถ๊ธํ๋ค์..! |
@@ -0,0 +1,88 @@
+const DATE = Object.freeze({
+ eventEndDay: 31,
+ christmasEndDay: 25,
+});
+
+const WEEKDAY = Object.freeze([
+ 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31,
+]);
+
+const WEEKEND = Object.freeze([1, 2, 8, 9, 15, 16, 22, 23, 29, 30]);
+
+const SPECIAL = Object.free... | JavaScript | DATE.eventEndDay ์์์ฒ๋ฆฌํํ์ ๋ถ๋ถ์ด ์ธ์๊น๋ค์:) |
@@ -0,0 +1,88 @@
+const DATE = Object.freeze({
+ eventEndDay: 31,
+ christmasEndDay: 25,
+});
+
+const WEEKDAY = Object.freeze([
+ 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31,
+]);
+
+const WEEKEND = Object.freeze([1, 2, 8, 9, 15, 16, 22, 23, 29, 30]);
+
+const SPECIAL = Object.free... | JavaScript | ํ์ผ์ ๋ํ ๋ ์ง๋ฅผ ์ง์ ์์ฑ ๋ฐ ์์์ฒ๋ฆฌํ์
์ WEEKDAY ๊ฐ์ฒด์์ ํด๋น ๋ ์ง๊ฐ ํฌํจ๋๋ ์ง๋ฅผ ๋น๊ตํ ๋ก์ง์ผ๋ก ์์๋ฉ๋๋ค.
๋ง์ฝ 2023๋
12์์ด๋ผ๋ ๋ฒ์์ ๊ฐ์ด ๋ณ๊ฒฝ์ด ๋๋ค๋ฉด (2024๋
1์์ ํ์ผ,2024๋
4์์ ํ์ผ ๋ฑ) ๋งค๋ฒ ๋ ์ง๋ฅผ ํ์ผ์ธ์ง ํ์ธํด ์ง์ ์ฒ๋ฆฌํด์ผ ํจ์ผ๋ก ํ์ฅ์ฑ์ ์ด๋ ค์์ด ์๊ธธ ๊ฒ ๊ฐ์์.
js ์์ ์ ๊ณตํ๋ ๋ด์ฅ ๊ฐ์ฒด Date ๋ฅผ ํ์ฉํด ํ์ผ์ ๊ตฌํ๋ ๋ฉ์๋๋ฅผ ํ์ฉํ๋ ๊ฑด ์ด๋ ์ ๊ฐ์? |
@@ -0,0 +1,88 @@
+const DATE = Object.freeze({
+ eventEndDay: 31,
+ christmasEndDay: 25,
+});
+
+const WEEKDAY = Object.freeze([
+ 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31,
+]);
+
+const WEEKEND = Object.freeze([1, 2, 8, 9, 15, 16, 22, 23, 29, 30]);
+
+const SPECIAL = Object.free... | JavaScript | ๋ก์ง์ ์ผ๊ด์ฑ์ด ๋์ ์ฝ๊ธฐ ๋งค์ฐ ํธํ๋ค์! |
@@ -0,0 +1,126 @@
+import { MENU_PRICE } from '../utils/constants.js';
+
+const MENU_TYPES = Object.freeze({
+ appetizer: ['์์ก์ด์ํ', 'ํํ์ค', '์์ ์๋ฌ๋'],
+ main: ['ํฐ๋ณธ์คํ
์ดํฌ', '๋ฐ๋นํ๋ฆฝ', 'ํด์ฐ๋ฌผํ์คํ', 'ํฌ๋ฆฌ์ค๋ง์คํ์คํ'],
+ dessert: ['์ด์ฝ์ผ์ดํฌ', '์์ด์คํฌ๋ฆผ'],
+ drink: ['์ ๋ก์ฝ๋ผ', '๋ ๋์์ธ', '์ดํ์ธ'],
+});
+
+const LIMIT_NUMBER = Object.freeze({
+ minN... | JavaScript | ํด๋น ์ฝ๋๋ฅผ ํด๋ก ๋ฐ๊ธฐ ์ด๋ ค์ด ์ํ๋ผ ์ ํํ ํ์ธํ๊ธฐ ์ด๋ ค์ ์กฐ์ฌ์ค๋ฝ๊ฒ ์ฌ์ญค๋ณด๋ค์ ใ
ํน์ ํด๋น ์ ๊ท์์ด "ํฐ๋ณธ์คํ
์ดํฌ-3" ์
๋ ฅ๋ฐ์๋ ํต๊ณผ๋๋์? |
@@ -0,0 +1,126 @@
+import { MENU_PRICE } from '../utils/constants.js';
+
+const MENU_TYPES = Object.freeze({
+ appetizer: ['์์ก์ด์ํ', 'ํํ์ค', '์์ ์๋ฌ๋'],
+ main: ['ํฐ๋ณธ์คํ
์ดํฌ', '๋ฐ๋นํ๋ฆฝ', 'ํด์ฐ๋ฌผํ์คํ', 'ํฌ๋ฆฌ์ค๋ง์คํ์คํ'],
+ dessert: ['์ด์ฝ์ผ์ดํฌ', '์์ด์คํฌ๋ฆผ'],
+ drink: ['์ ๋ก์ฝ๋ผ', '๋ ๋์์ธ', '์ดํ์ธ'],
+});
+
+const LIMIT_NUMBER = Object.freeze({
+ minN... | JavaScript | #orderMenu ์์ ๋ฐฐ์ด์ ํํ๋ก ๊ฐ๊ฐ์ ๋ฉ๋ด๊ฐ { menuName, count: Number(count), price, type } ๊ฐ์ฒด ํํ๋ก ๋ด๊ฒจ์ ธ ์ ์ฅ๋๋๊ฒ์ ํ์ธ๋ฉ๋๋ค.
๊ฐ๊ฐ์ ๋ฉ๋ด ๋ํ ํด๋์คํํ๋ก ์ ์ฅํ์ง ์๊ณ ๊ฐ์ฒด ๋ฆฌํฐ๋ด์ ํ์์ผ๋ก ์ ์ฅํ์ ์ด์ ๊ฐ ๊ถ๊ธํ๋ค์ :) |
@@ -0,0 +1,197 @@
+# ๐
๐ป ํฌ๋ฆฌ์ค๋ง์ค ํ๋ก๋ชจ์
๐
+
+## ์งํ ๋ฐฉ์
+
+### ๐ง๐ป ๊ณ ๊ฐ ๐ฉ๐ป
+
+- ๋ฐฉ๋ฌธํ ๋ ์ง๋ฅผ ์
๋ ฅํ๋ค.
+- ์ฃผ๋ฌธํ ๋ฉ๋ด ์ด๋ฆ๊ณผ ์๋์ ์
๋ ฅํ๋ค.
+
+### ๐ช ์๋น ๐ด
+
+1. ์๊ฐ๋ฌธ๊ตฌ๋ฅผ ์ถ๋ ฅํ๋ค.
+2. ๋ฐฉ๋ฌธ ๋ ์ง์ ์ด๋ฒคํธ ํํ ์๋ด๋ฌธ๊ตฌ๋ฅผ ์ถ๋ ฅํ๋ค.
+3. ๊ณ ๊ฐ์ด ์ฃผ๋ฌธํ ๋ฉ๋ด๋ฅผ ์ถ๋ ฅํ๋ค.
+4. ์ฃผ๋ฌธํ ๋ฉ๋ด์ ์ด ๊ธ์ก์ ์ถ๋ ฅํ๋ค.
+5. ์ฆ์ ๋ฉ๋ด์ ์ฌ๋ถ๋ฅผ ์ถ๋ ฅํ๋ค.
+6. ๋ฐ์ ์ ์๋ ๋ชจ๋ ํํ ๋ด์ญ์ ์ถ๋ ฅํ๋ค.
+7. ํํ๋ด์ญ์ ๋ชจ๋ ๋ํ ์ด ๊ธ์ก์ ์ถ๋ ฅํ๋ค.
+8. ์ด ์ฃผ๋ฌธ๊ธ์ก์์ ํ ์ธ๋๋ ... | Unknown | ์ ์ฑ๋ค์ฌ ์์ฑํ์ ๊ฒ ๋๊ปด์ง๋ README๋ค์ ๐ |
@@ -0,0 +1,88 @@
+const DATE = Object.freeze({
+ eventEndDay: 31,
+ christmasEndDay: 25,
+});
+
+const WEEKDAY = Object.freeze([
+ 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31,
+]);
+
+const WEEKEND = Object.freeze([1, 2, 8, 9, 15, 16, 22, 23, 29, 30]);
+
+const SPECIAL = Object.free... | JavaScript | ์ฌ์ํ๋ค๋ฉด ์ฌ์ํ ๋ถ๋ถ์ด์ง๋ง '[ERROR] '๋ ๋ชจ๋ ์์ธ ๋ฉ์์ง์์ ์ฌ์ฉ๋๋ฏ๋ก prefix๋ก ์์ํํ์๋ฉด ์ข์ ๊ฒ ๊ฐ์์. ๋ค์ ์ด์ด์ง๋ ์์ธ ๋ฉ์์ง๋ ๋ง์ฐฌ๊ฐ์ง๊ตฌ์! |
@@ -0,0 +1,126 @@
+import { MENU_PRICE } from '../utils/constants.js';
+
+const MENU_TYPES = Object.freeze({
+ appetizer: ['์์ก์ด์ํ', 'ํํ์ค', '์์ ์๋ฌ๋'],
+ main: ['ํฐ๋ณธ์คํ
์ดํฌ', '๋ฐ๋นํ๋ฆฝ', 'ํด์ฐ๋ฌผํ์คํ', 'ํฌ๋ฆฌ์ค๋ง์คํ์คํ'],
+ dessert: ['์ด์ฝ์ผ์ดํฌ', '์์ด์คํฌ๋ฆผ'],
+ drink: ['์ ๋ก์ฝ๋ผ', '๋ ๋์์ธ', '์ดํ์ธ'],
+});
+
+const LIMIT_NUMBER = Object.freeze({
+ minN... | JavaScript | https://regexr.com/
์ด ์ฌ์ดํธ ์ ์ฉํฉ๋๋ค! |
@@ -0,0 +1,35 @@
+package christmas.domain.discount.policy;
+
+import christmas.domain.common.Date;
+import christmas.domain.common.Money;
+import christmas.domain.discount.DateDiscountPolicy;
+import christmas.domain.discount.DiscountResult;
+
+public class ChristmasDDayDiscountPolicy extends DateDiscountPolicy {
+
+ ... | Java | ์ด๋ ๊ฒ ํ๋ฉด, ๋งค ๋ฐ๋ณต๋ง๋ค getDayOfMonth ๋ฉ์๋๋ฅผ ํธ์ถํ๊ธฐ ๋๋ฌธ์ ์ฑ๋ฅ๋ฉด์์ ์ข์ง ์์๊ฑฐ ๊ฐ์์! ์ง๊ธ์ getDayOfMonth์ ๋ณต์กํ ๋ก์ง์ด ์์ด ํฌ๊ฒ ์ฐจ์ด๋ ์์๊ฑฐ ๊ฐ์ง๋ง, ์์ ๊ฐ์ ์ฝ๋๋ ์ฑ๋ฅ ์ด์๊ฐ ๋ฐ์ํ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ํด๋น ๋ฉ์๋์ ๊ฐ์ ๋ณ์๋ก ํ ๋นํด ์ฌ์ฉํ๋ ๊ฒ์ ์ด๋ค๊ฐ์? ๐ |
@@ -0,0 +1,55 @@
+package christmas.domain.menu;
+
+import christmas.domain.common.Date;
+import christmas.domain.common.Money;
+import christmas.domain.discount.DateDiscountPolicy;
+import christmas.domain.discount.DiscountResult;
+import java.util.Objects;
+
+public abstract class AbstractMenu implements Menu {
+
+ ... | Java | ์ค์ ์ถ์ ํด๋์ค๋ก ์ ์ธํ ์ด์ ๊ฐ ๊ถ๊ธํด์. ์ ๊ฐ ๋ดค์ ๋ ์ถ์ ๋ฉ์๋๊ฐ ์๋๊ฑฐ ๊ฐ์๋ฐ ๋ง์๊น์? ์ถ์ ๋ฉ์๋๊ฐ ์๋๋ฐ ์ถ์ ํด๋์ค๋ก ์ ์ธํ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค! |
@@ -0,0 +1,35 @@
+package christmas.domain.discount.policy;
+
+import christmas.domain.common.Date;
+import christmas.domain.common.Money;
+import christmas.domain.discount.DateDiscountPolicy;
+import christmas.domain.discount.DiscountResult;
+
+public class ChristmasDDayDiscountPolicy extends DateDiscountPolicy {
+
+ ... | Java | ๋ถ๊ณผ ๋ช๋ฌ์ ์ ์ฑ
์์ ๋ดค๋ ๋ด์ฉ์ด๋ค์.. ์ด์ ์ ๋ ๊น๋จน์๋ฆฌ ์์ ๊ฒ ๊ฐ๋ค์! ๊ฐ์ฌํฉ๋๋ค ๐๐ปโโ๏ธ |
@@ -0,0 +1,55 @@
+package christmas.domain.menu;
+
+import christmas.domain.common.Date;
+import christmas.domain.common.Money;
+import christmas.domain.discount.DateDiscountPolicy;
+import christmas.domain.discount.DiscountResult;
+import java.util.Objects;
+
+public abstract class AbstractMenu implements Menu {
+
+ ... | Java | ์ง์ ์์ฑํ๋ ๊ฒ์ ๋ง๊ณ , ๊ณตํต ๋ก์ง์ ์ฌ์ฌ์ฉํ๊ธฐ ์ํด์ abstract๋ก ๋ง๋ค์์ด์! ํ์ง๋ง, ํ๋๋์ฒ๋ผ ํ์
๊ธฐ๋ฐ์ผ๋ก ๋ฉ๋ด๋ฅผ ๋ถ๋ฅํ๋ฉด ์ด๋ฐ ์ฝ๋๋ ๋ถํ์ํ ๊ฒ ๊ฐ๋ค์! |
@@ -0,0 +1,77 @@
+package christmas.domain.common;
+
+import static christmas.global.util.ObjectUtil.requireNonNull;
+
+import christmas.global.util.DateUtil;
+import java.util.Objects;
+
+public class Date {
+
+ public static final int BASE_MONTH = 12;
+ private static final int BASE_YEAR = 2023;
+ private st... | Java | > ๋ฐฉ๋ฌธํ ๋ ์ง๋ 1 ์ด์ 31 ์ดํ์ ์ซ์๋ก๋ง ์
๋ ฅ๋ฐ์ ์ฃผ์ธ์.
> 1 ์ด์ 31 ์ดํ์ ์ซ์๊ฐ ์๋ ๊ฒฝ์ฐ, "[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์."๋ผ๋ ์๋ฌ ๋ฉ์์ง๋ฅผ ๋ณด์ฌ ์ฃผ์ธ์.
์๊ตฌ์ฌํญ์์ ๋ช
์ํ ์์ธ ๋ฉ์์ง ๋ง๊ณ ์ด๋ฌํ ์์ธ ๋ฉ์์ง๋ฅผ ์ ํํ ์ด์ ๋ ๊ตฌ์ฒด์ฑ์ ๋์ด๊ธฐ ์ํจ์ด์๋์ ? ๐ |
@@ -0,0 +1,63 @@
+package christmas.domain.common;
+
+import static christmas.global.util.ObjectUtil.requireNonNull;
+
+import java.util.Objects;
+
+public class Money {
+
+ private static final int ZERO_MONEY_AMOUNT = 0;
+ private static final String UNKNOWN_MONEY_MESSAGE = "์ ์ ์๋ ๋๊ณผ ํด๋น ์ฐ์ฐ์ ์ํํ ์ ์์ต๋๋ค.";
+ p... | Java | ๋ถ๋ณ ๊ฐ์ฒด๋ก ํ์ฉํ ์ ์ด ์ข๋ค์ ~ ๐ |
@@ -0,0 +1,30 @@
+package christmas.domain.discount;
+
+import static christmas.global.util.ObjectUtil.requireNonNull;
+
+import christmas.domain.common.Date;
+
+public abstract class DateDiscountPolicy {
+
+ private static final String UNKNOWN_DATE_MESSAGE = "์ ์ ์๋ ๋ ์ง์
๋๋ค.";
+ private static final String CANT_AP... | Java | ํ์ ์์ ๊ตฌํ์ฒด๊ฐ ์์ ๋ถ๋ชจ ๊ฐ์ฒด์ ๋ก์ง์ ์ํฅ์ ์ฃผ๊ธฐ ์ํด์ protected abstract๋ก ์ ์ธํ ๊ฒ์ด ์ธ์์ ์ด๋ค์~ ๐ |
@@ -0,0 +1,18 @@
+package christmas.domain.discount.policy;
+
+import christmas.domain.common.Date;
+import christmas.domain.discount.DateDiscountPolicy;
+import christmas.domain.discount.DiscountResult;
+
+public class NoneDiscountPolicy extends DateDiscountPolicy {
+
+ @Override
+ protected boolean isSatisfied(... | Java | ํด๋น Policy๋ ์ด๋ค ์ด์ ๋๋ฌธ์ ๊ตฌ์ฑํ์
จ๋์ ~ ? ๐ |
@@ -0,0 +1,35 @@
+package christmas.domain.discount.policy;
+
+import christmas.domain.common.Date;
+import christmas.domain.common.Money;
+import christmas.domain.discount.DateDiscountPolicy;
+import christmas.domain.discount.DiscountResult;
+
+public class ChristmasDDayDiscountPolicy extends DateDiscountPolicy {
+
+ ... | Java | ๊ฐ์ธ์ ์ผ๋ก ์ ํ ์ธ๋ ๊ธ์ก์ ์์ ๊ฐ์ผ๋ก ์ ์งํ๊ณ , View๋ก ๋ณด์ฌ์ฃผ๋ ์์ ์ "-" ๋ง์ด๋์ค ๋ถํธ๋ฅผ ๋ถ์ฌ์ฃผ๋๋ก ํ์ฉํจ์ผ๋ก์จ
์ด ๊ธ์ก์ด ์ฃผ๋ฌธ ๊ธ์ก์์ ์ผ๋ง๋ ๋นผ์ผ ํ ๊ธ์ก์ธ์ง๋ฅผ ์ง๊ด์ ์ผ๋ก ์ดํดํ ์ ์๋๋ก ์๋ํ๋๋ฐ
ํ๋๋์ ์ด๋ค ์ด์ ๋๋ฌธ์ ์ฒ์๋ถํฐ ํ ์ธ๋ ๊ธ์ก์ ์์ ๊ฐ์ผ๋ฃ ์ ์งํ๊ณ ์ ํ์
จ๋์~? ๐ |
@@ -0,0 +1,35 @@
+package christmas.domain.discount.policy;
+
+import christmas.domain.common.Date;
+import christmas.domain.common.Money;
+import christmas.domain.discount.DateDiscountPolicy;
+import christmas.domain.discount.DiscountResult;
+import java.util.List;
+
+public class SpecialDiscountPolicy extends DateDis... | Java | ํน๋ณํ ๋ ์ง๋ฅผ ๊ด๋ฆฌํ๊ธฐ ์ํด์ List๋ฅผ ํ์ฉํ์
จ๋๋ฐ, Set์ ์ด๋จ๊น์~ ? ๐ |
@@ -0,0 +1,46 @@
+package christmas.domain.menu;
+
+import static christmas.global.util.ObjectUtil.requireIncludeNonNull;
+import static christmas.global.util.ObjectUtil.requireNonNull;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+
+public class Menus {
+
+ private static final St... | Java | List์ Set์ผ๋ก ๋ณ๊ฒฝํด์ ํ์ธํ๋ ๋ถ๋ถ์ด ์ข๋ค์ ~ ๐ |
@@ -0,0 +1,77 @@
+package christmas.domain.common;
+
+import static christmas.global.util.ObjectUtil.requireNonNull;
+
+import christmas.global.util.DateUtil;
+import java.util.Objects;
+
+public class Date {
+
+ public static final int BASE_MONTH = 12;
+ private static final int BASE_YEAR = 2023;
+ private st... | Java | ๋ต ๋ง์ต๋๋ค. ์๊ตฌ์ฌํญ์ ๋์ค๋ ์์ธ ๋ฉ์์ง๋ ๋๋ฌด ์ผ๋ฐ์ ์ฌ์์. ๊ฐ๋ฐํ๋ฉด์ ๋ก๊ทธ๋ฅผ ์ฐ์ด ๋ณผ ์ผ์ด ์์๋๋ฐ, ๋ถํธํ๋๋ผ๊ตฌ์. ๋ฐ๋ผ์, ์์ ๊ฐ์ด ๊ตฌ์ฒด์ ์ผ๋ก ๋ด๋ณด๋ด๊ณ , ๋ค์ ์ปจํธ๋กค๋ฌ์์ ๋ฉ์์ง๋ฅผ ๋ฐ๊พธ๋ ์์
์ ํด์คฌ์ต๋๋ค! |
@@ -0,0 +1,18 @@
+package christmas.domain.discount.policy;
+
+import christmas.domain.common.Date;
+import christmas.domain.discount.DateDiscountPolicy;
+import christmas.domain.discount.DiscountResult;
+
+public class NoneDiscountPolicy extends DateDiscountPolicy {
+
+ @Override
+ protected boolean isSatisfied(... | Java | ```java
@Override
public DiscountResult calculateDiscountBenefitWith(Date date, int quantity) {
DiscountResult menuDiscountResult = policy.discount(date);
return new DiscountResult(menuDiscountResult.policyName(), menuDiscountResult.amount().multiply(quantity));
}
```
DateDiscountPolicy๋ฅผ ์ฌ์ฉํ๋ ํด๋ผ์ด์ธํธ... |
@@ -0,0 +1,35 @@
+package christmas.domain.discount.policy;
+
+import christmas.domain.common.Date;
+import christmas.domain.common.Money;
+import christmas.domain.discount.DateDiscountPolicy;
+import christmas.domain.discount.DiscountResult;
+
+public class ChristmasDDayDiscountPolicy extends DateDiscountPolicy {
+
+ ... | Java | View์์ ๋ง์ด๋์ค ๋ถํธ๋ฅผ ์ถ๊ฐํด์ฃผ๋ ๊ฒ์ด ๋ฒ๊ฑฐ๋ก์์ ๊ทธ๋ฐ์์ผ๋ก ๊ตฌํํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ํ์คํ ์์๋ก ํ๋ ๊ฒ์ด, ๋ง์ ์ฃผ์ ๊ฒ์ฒ๋ผ ๋์ฑ ์ง๊ด์ ์ธ ๊ฒ ๊ฐ์์!
++ Money์ substract ์ฐ์ฐ์ ๋ง๋ ์ด์ ๋ ์ฒ์์๋ ํ ์ธ ๊ฐ์ ์์๋ก ์ ์งํ๋ ค๊ณ ํ๋ ๊ฒ ๊ฐ์๋ฐ์. ์ง๊ธ๋ณด๋, money.substract๋ฅผ ํ
์คํธ ์ฝ๋์์๋ง ์ฌ์ฉํ๋๊ตฐ์... ํผ๋๋ฐฑ ๊ฐ์ฌํฉ๋๋ค. |
@@ -0,0 +1,17 @@
+package christmas.domain.menu
+
+import christmas.exception.OrdersException
+
+data class MenuCount(private val count: Int) {
+ init {
+ require(count >= 1) { OrdersException.INVALID.message }
+ }
+
+ fun getCount() = count
+
+ override fun toString(): String = "%,d$UNIT_SUFFIX".for... | Kotlin | val ์ ์ธ ๋๋ฌธ์ ๋ฐ๋ก private๋ก ์ ํํ์ง ์์๋ ๊ฐ ์์ ์ด ๋ถ๊ฐ๋ฅํ ํ
๋ฐ, ํน์ private๋ก ์ ์ธํ ์ด์ ๊ฐ ๋ฐ๋ก ์์๊น์..?! |
@@ -0,0 +1,29 @@
+package christmas.domain
+
+import christmas.exception.DecemberDayException
+
+data class DecemberDay(private val day: Int) {
+ init {
+ require(day in DAY_START..DAY_END) { DecemberDayException.INVALID.message }
+ }
+
+ fun hasPassedChristmas() = day > DAY_CHRISTMAS
+ fun getDaySin... | Kotlin | ์ด๋ถ๋ถ์ fromString ๋ณด๋ค๋ checkDay๊ฐ ์ข๋ ์์ฐ์ค๋ฌ์ ๋ณด์
๋๋ค..!! ๊ฐ์ธ์ ์ผ๋ก fromString์ ๋ณด๋ฉด toString์ฒ๋ผ String ํฌ๋งท ํจ์์ฒ๋ผ ๋ณด์ฌ์..!! |
@@ -0,0 +1,90 @@
+package christmas.domain
+
+import christmas.domain.benefit.Benefit
+import christmas.domain.benefit.BenefitType
+import christmas.domain.benefit.Benefits
+import christmas.domain.menu.*
+
+class DecemberEvent {
+
+ fun getFreeGift(totalOrderAmount: Money): FreeGift? {
+ if (!totalOrderAmoun... | Kotlin | ์ฝ๋๋ฅผ ๋ค๋ฃจ๋ ๊ด์ ์ ๋ฐ๋ผ ๋ค๋ฅด๊ฒ ์ง๋ง, ์ ๋ ์๋ฐ์ ์ฝํ๋ฆฐ์ ๊ฐ์ฅ ํฐ ์ฐจ์ด์ ์ null ์์ ์ฑ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค..!!
non-null type์ด ๋ํดํธ์ธ ์ฝํ๋ฆฐ์ ์ฅ์ ์ ์ด๋ ค์, ๋๋๋ก์ด๋ฉด null์ ๋ฐํํ์ง ์๋๋ก ๊ณ ๋ฏผํด๋ด๋ ์ข์๊ฑฐ๊ฐ์์!!๐๐ |
@@ -0,0 +1,90 @@
+package christmas.domain
+
+import christmas.domain.benefit.Benefit
+import christmas.domain.benefit.BenefitType
+import christmas.domain.benefit.Benefits
+import christmas.domain.menu.*
+
+class DecemberEvent {
+
+ fun getFreeGift(totalOrderAmount: Money): FreeGift? {
+ if (!totalOrderAmoun... | Kotlin | ์ ์ง์ง ์ฌ์ํ ์คํ ๋ฐ๊ฒฌํ๋ค์๐
|
@@ -0,0 +1,94 @@
+package christmas.domain
+
+import org.assertj.core.api.Assertions
+import org.junit.jupiter.api.Assertions.*
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.params.ParameterizedTest
+import org.junit.jupiter.params.provider.ValueSource
+
+class DecemberDayTest {
+ @ParameterizedTest
+... | Kotlin | @ValueSource ๋ณด๋๊น ๋น๊ฐ ์์ธ์ฒ๋ฆฌ๋ ๊ฐ์ด ํ
์คํธํ๋๊ฑฐ ๊ฐ์๋ฐ, ๋ฐ๋ก ํจ์๋ฅผ ๋ ์ด์ ๊ฐ ํน์ ์์๊น์..? |
@@ -0,0 +1,14 @@
+package christmas.domain
+
+data class Money(private val amount: Int) {
+
+ fun toNegative() = Money(-amount)
+ fun isGreaterOrEqual(other: Money): Boolean = amount >= other.amount
+ fun plus(other: Money): Money = Money(amount + other.amount)
+ fun multiplyBy(input: Int): Money = Money(am... | Kotlin | ์ฌ์ค ์ ๋ ์ด๋ฒ ๋ฏธ์
์ ํ๋ฉด์ ๊ฐ์ฅ ํท๊ฐ๋ ธ๋ ์ ์ **์ด๋๊น์ง๋ฅผ ๊ฐ์ฒด๋ก** ๋ด์ผํ๋๊ฐ ์์ต๋๋ค!
์ฝ๋๋ฆฌ๋ทฐ๋ฅผ ํ๋ฉด์ ํ์ฅ์ฑ๊ณผ ์ ์ง๋ณด์๋ฅผ ์ํ ๊ด์ฌ์ฌ ๋ถ๋ฆฌ๋ ํ์์ง๋ง, ์คํ๋ ค ๊ณผ๋ํ ๊ฐ์ฒด ๋ถ๋ฆฌ๋ ์คํ๋ ค ์ฝ๋ ๊ฐ๋
์ฑ์ ํด์น๋ค๋ ์๊ฐ๋ ๋ง์ด ๋ค์์ต๋๋ค. multiplyBy์ ๊ฒฝ์ฐ, ํจ์์ ๋ป๋ง ๋ดค์ ๋๋ ๊ณฑ์
์ฐ์ฐ์ธ ๊ฒ์ ์ ์ ์์ง๋ง ํน์๋ ๋ฐ๋ก ํจ์๋ก ๋นผ๋ ์ด์ ๊ฐ ์์๊น๋ด ์ฝ๋๋ฅผ ์ฐพ๋๋ฐ ์๊ฐ์ ์์ํ์์ต๋๋ค! ๊ฐ์ธ์ ์ผ๋ก๋ ๊ฐ์ฒด๋ฅผ ์กฐ๊ธ ์ค์ฌ๋ ๋์ง ์์๊น ์ถ์ด์...!!!
๋๋ฌด ์ํ์
์ ์ด๋ฐ ๋ฆฌ๋ทฐ๋ฐ์ ๋ชป๋๋ฆฌ๋ค์ ์ฃ์กํฉ๋๋ค๐๐ |
@@ -0,0 +1,17 @@
+package christmas.domain.menu
+
+import christmas.exception.OrdersException
+
+data class MenuCount(private val count: Int) {
+ init {
+ require(count >= 1) { OrdersException.INVALID.message }
+ }
+
+ fun getCount() = count
+
+ override fun toString(): String = "%,d$UNIT_SUFFIX".for... | Kotlin | ์ฌ์ค ์ ๋ ์ด ๋ถ๋ถ์ด ๋ง์ด ๊ณ ๋ฏผ๋์ด์
์๋์ผ๋ก ์์ฑ๋๋ getter ๋ฉ์๋๋ฅผ ์ด์ฉํ ์ง, ํน์ ์ง์ ์ด๋ ๊ฒ ํจ์๋ก ๊ตฌํํ ์ง ๊ณ ๋ฏผ์ด ๋๋๋ฐ ์ผ๋จ private๋ก ํต์ผ์ ํ๊ณ ๋ฉ์๋๋ฅผ ์ ๊ณตํ๋๊ฒ ๊ฐ๋
์ฑ์ด ์ข์๊ฒ ๊ฐ์์ ์๋ํด๋ดค์ด์! |
@@ -0,0 +1,29 @@
+package christmas.domain
+
+import christmas.exception.DecemberDayException
+
+data class DecemberDay(private val day: Int) {
+ init {
+ require(day in DAY_START..DAY_END) { DecemberDayException.INVALID.message }
+ }
+
+ fun hasPassedChristmas() = day > DAY_CHRISTMAS
+ fun getDaySin... | Kotlin | ์ํ ์ธ๋ป ๋ณด๋ฉด String ํฌ๋งท ํจ์๋ ํท๊ฐ๋ฆด ์ ์๊ฒ ๋ค์! ์ข์ ์๊ฒฌ ๊ฐ์ฌํฉ๋๋ค
์๋๋ ๊ฐ์ฒด๋ฅผ ์์ฑํ ๋ ๋ฌธ์์ด๋ก๋ถํฐ ์์ฑํ๋ค๋ ์๋ฏธ๋ฅผ ์ค๋ ค๊ณ ํ๋๋ฐ ๋ค์ ์ ๋งคํ ํํ์ด ๋ ์ ์๊ฒ ๋ค์๐ |
@@ -0,0 +1,90 @@
+package christmas.domain
+
+import christmas.domain.benefit.Benefit
+import christmas.domain.benefit.BenefitType
+import christmas.domain.benefit.Benefits
+import christmas.domain.menu.*
+
+class DecemberEvent {
+
+ fun getFreeGift(totalOrderAmount: Money): FreeGift? {
+ if (!totalOrderAmoun... | Kotlin | ๋น์์๋ Null ํ์
์ด ํด๋น ์์์ ํํํ๊ธฐ ์ ํฉํ๋ค ์๊ฐํ์๋๋ฐ ๋ง์ํ์ ๊ฒ์ฒ๋ผ ์ฝํ๋ฆฐ ์ธ์ด ํน์ฑ์ non-null ํ์
์ผ๋ก ์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ ๋ณด์ด๋ค์! ์ด๋ป๊ฒ ๋ณํํด์ผ ํ ์ง ๊ณ ๋ฏผํด๋ด์ผ๊ฒ ์ด์ |
@@ -0,0 +1,90 @@
+package christmas.domain
+
+import christmas.domain.benefit.Benefit
+import christmas.domain.benefit.BenefitType
+import christmas.domain.benefit.Benefits
+import christmas.domain.menu.*
+
+class DecemberEvent {
+
+ fun getFreeGift(totalOrderAmount: Money): FreeGift? {
+ if (!totalOrderAmoun... | Kotlin | ์ D-Day์ธ๋ฐ ๋ถ์ฌ ์ฐ๋ค ๋ณด๋ ์คํ๋ก ๋ณด์ผ ์ ์์๋ค์๐คฃ |
@@ -0,0 +1,94 @@
+package christmas.domain
+
+import org.assertj.core.api.Assertions
+import org.junit.jupiter.api.Assertions.*
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.params.ParameterizedTest
+import org.junit.jupiter.params.provider.ValueSource
+
+class DecemberDayTest {
+ @ParameterizedTest
+... | Kotlin | ์ด ๋ถ๋ถ์ ๋์น๊ณ ์์๋ค์..!! ์๋๋ ์ค์์
๋๋ค! |
@@ -0,0 +1,14 @@
+package christmas.domain
+
+data class Money(private val amount: Int) {
+
+ fun toNegative() = Money(-amount)
+ fun isGreaterOrEqual(other: Money): Boolean = amount >= other.amount
+ fun plus(other: Money): Money = Money(amount + other.amount)
+ fun multiplyBy(input: Int): Money = Money(am... | Kotlin | ์๋์์!! ํผ์ ๋ณผ ๋๋ ์ต์ํด์ ธ ๋ณด์ด์ง ์์๋ ๋ถ๋ถ๋ค๋ ๋ณด์ด๊ฒ ๋๊ณ ๋ค์ํ ์์ ์์ ๊ณ ๋ฏผํ ๋ถ๋ถ์ด ๋ง์์ก์ด์๐
์์คํ ๋ฆฌ๋ทฐ ๋จ๊ฒจ์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค!! |
@@ -0,0 +1,90 @@
+package christmas.domain
+
+import christmas.domain.benefit.Benefit
+import christmas.domain.benefit.BenefitType
+import christmas.domain.benefit.Benefits
+import christmas.domain.menu.*
+
+class DecemberEvent {
+
+ fun getFreeGift(totalOrderAmount: Money): FreeGift? {
+ if (!totalOrderAmoun... | Kotlin | ์!!!! ์ด์ง ๋ถ๋๋ฝ๋ค์๐ณ |
@@ -0,0 +1,40 @@
+const food = {
+ APPETIZER: ['์์ก์ด์ํ', 'ํํ์ค', '์์ ์๋ฌ๋'],
+ MAIN: ['ํฐ๋ณธ์คํ
์ดํฌ', '๋ฐ๋นํ๋ฆฝ', 'ํด์ฐ๋ฌผํ์คํ', 'ํฌ๋ฆฌ์ค๋ง์คํ์คํ'],
+ DESSERT: ['์ด์ฝ์ผ์ดํฌ', '์์ด์คํฌ๋ฆผ'],
+ BEVERAGE: ['์ ๋ก์ฝ๋ผ', '๋ ๋์์ธ', '์ดํ์ธ'],
+};
+
+const foodCost = {
+ ์์ก์ด์ํ: 6000,
+ ํํ์ค: 5500,
+ ์์ ์๋ฌ๋: 8000,
+ ํฐ๋ณธ์คํ
์ดํฌ: 55000,
+ ๋ฐ๋นํ๋ฆฝ: 54000,
+ ํด์ฐ๋ฌผํ์คํ: 35000,
+... | JavaScript | ์ฝ์ค ๋ฐ๋ก ๊ฐ๊ฒฉ ๋ฐ๋ก ๋ฐ์ดํฐ๋ฅผ ๋ง๋์
จ๊ตฐ์!
์ ๋ ์ฒ์์ ์ด๋ ๊ฒ ๊ฐ๊ฐ ๋ง๋ค๋ ค๊ณ ํ๋๋ฐ, ์ด๋ ๊ฒ ํ๋ฉด ๋์ค์ ์์ ํด์ผ ํ ๋ ๊ฐ์ ์์์ ์ฌ๋ฌ๋ฒ ์ฌ๋ฌ๊ณณ์์ ์์ ํด์ค์ผ ํ ๊ฒ ๊ฐ๋ค๋ ์๊ฐ์ด ๋ค์ด์,
์ ํ ์์์ ์ฝ์ค, ๊ฐ๊ฒฉ ์ ๋ณด๋ฅผ ๋ด์์ ์์๋ค์ Map ํํ๋ก ๋ฐ์ดํฐํ์ต๋๋ค!
์ด ์ธ์๋ ๋ค๋ฅธ ๋ ์ข์ ๋ฐฉ๋ฒ์ด ์์ผ์๋ค๋ฉด ๊ณต์ ๋ถํ๋๋ ค์! ใ
ใ
|
@@ -0,0 +1,32 @@
+const uiConstants = {
+ DATE: 'DATE',
+ MENU: 'MENU',
+ GREETING_MESSAGE: '์๋
ํ์ธ์! ์ฐํ
์ฝ ์๋น 12์ ์ด๋ฒคํธ ํ๋๋์
๋๋ค.',
+ WHEN_VISIT_MESSAGE:
+ '12์ ์ค ์๋น ์์ ๋ฐฉ๋ฌธ ๋ ์ง๋ ์ธ์ ์ธ๊ฐ์? (์ซ์๋ง ์
๋ ฅํด ์ฃผ์ธ์!)\n',
+ ORDER_MENU_MESSAGE:
+ '์ฃผ๋ฌธํ์ค ๋ฉ๋ด๋ฅผ ๋ฉ๋ด์ ๊ฐ์๋ฅผ ์๋ ค ์ฃผ์ธ์. (e.g. ํด์ฐ๋ฌผํ์คํ-2,๋ ๋์์ธ-1,์ด์ฝ์ผ์ดํฌ-1)\n',
+ PREVIEW_EVENT_MESSAGE: '์ผ์... | JavaScript | ์ ์์๋ค์ ๋ชจ๋ constants ๋ผ๋ ํ์ผ์ ๋ชฐ์ ๋ฃ์๋๋ฐ,
์ด๋ ๊ฒ ๊ตฌ๋ถํด๋์ผ๋๊น ํจ์ฌ ๊น๋ํ๊ณ ๊ฐ๋
์ฑ๋ ์ข์๋ณด์ด๋๊ตฐ์!! |
@@ -0,0 +1,21 @@
+import { foodCost } from '../constants/index.js';
+
+// ๋ฌธ์์ด์ธ ์ฃผ๋ฌธ๋ชฉ๋ก์ Map ๊ฐ์ฒด๋ก ๋ณํ
+export const createMapObj = (menuStr) => {
+ const menuArr = menuStr.split(',');
+ const menuObj = new Map();
+ menuArr.forEach((menu) => {
+ const tmp = menu.split('-');
+ menuObj.set(tmp[0], Number(tmp[1]));
+ }... | JavaScript | ํน์ tmp ๋ ์ด๋ค ๋จ์ด์ ์ฝ์์ผ๊น์..?? ํ
ํ๋ฆฟ..?์ธ๊ฐ์? |
@@ -0,0 +1,114 @@
+import {
+ error,
+ magicNumber,
+ uiConstants,
+ food,
+ menuBoard,
+} from './constants/index.js';
+import { createMapObj } from './utils/index.js';
+
+export default class Validate {
+ excute(obj, type) {
+ switch (type) {
+ case uiConstants.DATE:
+ this.#dateValidate(obj);
+ ... | JavaScript | 1.1 ๊ฐ์ ์์์ ์ ์์ฑํ์๋ ์๊ธฐ์น ๋ชปํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์ ์์ ๊ฒ ๊ฐ์์!!
์์ ์ ์์ธ์ง ๊ฒ์ฆํ๋ ๋ก์ง์ด ์์ผ๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,42 @@
+import { createTotalCost } from '../utils/index.js';
+import { EventDiscount, EventCheck, Planner } from './index.js';
+
+// ์ ์ฒด์ ์ธ ์ด๋ฒคํธ๋ฅผ ์ถ๋ ฅํด์ฃผ๋ ํ๋๋ ํด๋์ค
+export default class PlannerPrint {
+ #date;
+
+ #menu;
+
+ constructor(date, menu) {
+ this.#date = Number(date);
+ this.#menu = menu;
+ }
+
... | JavaScript | ํ๋๋์ ํ๋๋ํ๋ฆฐํธ๋ฅผ ๋๋ ๋์ผ์ ์ด์ ๊ฐ ์์ผ์ค๊น์?? ๊ถ๊ธํฉ๋๋ค ใ
ใ
ใ
! |
@@ -0,0 +1,114 @@
+import {
+ error,
+ magicNumber,
+ uiConstants,
+ food,
+ menuBoard,
+} from './constants/index.js';
+import { createMapObj } from './utils/index.js';
+
+export default class Validate {
+ excute(obj, type) {
+ switch (type) {
+ case uiConstants.DATE:
+ this.#dateValidate(obj);
+ ... | JavaScript | ์ ํจ์ฑ ๊ฒ์ฌ๋ฅผ ๋ฐ๋ก ๋ชจ์๋๋ฉด ์ ์คํ๋ ค ๋๋ฌด ์ ๋ฆฌ๊ฐ ์๋์ด ๋ณด์ผ๊ฑฐ๋ผ๊ณ ์๊ฐํ๋๋ฐ, ์ด๋ ๊ฒ switch ๋ฌธ๊ณผ ํจ๊ป ๊น๋ํ๊ฒ๋ ์ธ ์ ์๊ตฐ์..! |
@@ -0,0 +1,21 @@
+import { foodCost } from '../constants/index.js';
+
+// ๋ฌธ์์ด์ธ ์ฃผ๋ฌธ๋ชฉ๋ก์ Map ๊ฐ์ฒด๋ก ๋ณํ
+export const createMapObj = (menuStr) => {
+ const menuArr = menuStr.split(',');
+ const menuObj = new Map();
+ menuArr.forEach((menu) => {
+ const tmp = menu.split('-');
+ menuObj.set(tmp[0], Number(tmp[1]));
+ }... | JavaScript | ์ ๋ ๋ก์ง์์ ํ๋์ ๊ฐ์ ๋์ถํ๋ ๊ฒฝ์ฐ์๋ `reduce` ๋ฉ์๋๊ฐ ๋ ์ ํฉํ๋ค๊ณ ์๊ฐํ๋๋ฐ ์ด๋ป๊ฒ ์๊ฐํ์๋์?? |
@@ -0,0 +1,28 @@
+const magicNumber = {
+ ZERO: 0,
+ EVENT_START: 1,
+ EVENT_END: 25,
+ WEEK: 7,
+ GIFT_COST: 120000,
+ MIN_COST: 10000,
+ DDAY_DISCOUNT: 1000,
+ DISCOUNT_UNIT: 100,
+ DESSERT_DISCOUNT: 2023,
+ MAIN_DISCOUNT: 2023,
+ SPECIAL_DISCOUNT: 1000,
+ FREE_GIFT_CNT: 1,
+ CHAMPAGNE_COST: 25000,
+ ST... | JavaScript | ์ด๋ฒ์ ๋ง์ ์ซ์๋ฅผ ๋ค๋ฃจ๋ฉด์ `numeric seperator` ๋ผ๋ ๊ฐ๋
์ ์ฒ์ ์๊ณ ์ ์ฉํด ๋ณด์๋๋ฐ
์ซ์ ๋จ์ ํ์
์ ์ด์ ์ด ์์๋ ๊ฒ ๊ฐ์์!
ํ๋ฒ ์ ์ฉํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค
```
GIFT_COST: 120_000,
``` |
@@ -0,0 +1,21 @@
+import { foodCost } from '../constants/index.js';
+
+// ๋ฌธ์์ด์ธ ์ฃผ๋ฌธ๋ชฉ๋ก์ Map ๊ฐ์ฒด๋ก ๋ณํ
+export const createMapObj = (menuStr) => {
+ const menuArr = menuStr.split(',');
+ const menuObj = new Map();
+ menuArr.forEach((menu) => {
+ const tmp = menu.split('-');
+ menuObj.set(tmp[0], Number(tmp[1]));
+ }... | JavaScript | temporary - ์์๋ผ๋ ๋ป์ด์๋๋ฐ
์ฌ์ค ์ ๊ฒ ๋ฏธ๋ฆฌ ์๋ฌด ๋ณ์๋ช
์ด๋ ์์ฑํ๊ณ ,
๋์ค์ ๊ณ ์ณค์ด์ผ ํ๋๋ฐ, ๋ฏธ์ฒ ํ์ธ์ ํ์ง ๋ชปํ๋ค์.. |
@@ -0,0 +1,42 @@
+import { createTotalCost } from '../utils/index.js';
+import { EventDiscount, EventCheck, Planner } from './index.js';
+
+// ์ ์ฒด์ ์ธ ์ด๋ฒคํธ๋ฅผ ์ถ๋ ฅํด์ฃผ๋ ํ๋๋ ํด๋์ค
+export default class PlannerPrint {
+ #date;
+
+ #menu;
+
+ constructor(date, menu) {
+ this.#date = Number(date);
+ this.#menu = menu;
+ }
+
... | JavaScript | ์ด๋ฒ์ UI๋ก์ง๊ณผ ๋น์ฆ๋์ค ๋ก์ง์ ํ์คํ ๋ถ๋ฆฌ์์ผ ๋ณด๊ณ ์ถ์์ต๋๋ค.
๊ทธ๋์ ๋ง์ง๋ง ํ๋๋ ๋ด์ฉ์ ๋ค ์ถ๋ ฅํ๋ ์ญํ ๋ง ํ๋ PlannerPrint์
์ถ๋ ฅํ๊ธฐ ์ํ ๋ก์ง์ ๋ด์ Planner๋ก ๋๋ ๋ดค์ต๋๋ค.
์ด๋ ๊ฒ ๋๋๋๊ฒ ๋ง๋์ง๋ ํ์คํ์ง๋ ์๋ค๐ |
@@ -0,0 +1,114 @@
+import {
+ error,
+ magicNumber,
+ uiConstants,
+ food,
+ menuBoard,
+} from './constants/index.js';
+import { createMapObj } from './utils/index.js';
+
+export default class Validate {
+ excute(obj, type) {
+ switch (type) {
+ case uiConstants.DATE:
+ this.#dateValidate(obj);
+ ... | JavaScript | ์์ด๊ณ .. ๊ทธ ๋ถ๋ถ์ ๋์ณค๋ค์ ใ
ใ
|
@@ -0,0 +1,21 @@
+import { foodCost } from '../constants/index.js';
+
+// ๋ฌธ์์ด์ธ ์ฃผ๋ฌธ๋ชฉ๋ก์ Map ๊ฐ์ฒด๋ก ๋ณํ
+export const createMapObj = (menuStr) => {
+ const menuArr = menuStr.split(',');
+ const menuObj = new Map();
+ menuArr.forEach((menu) => {
+ const tmp = menu.split('-');
+ menuObj.set(tmp[0], Number(tmp[1]));
+ }... | JavaScript | ๊ฐ๋จํ ๋ก์ง์ด ํ์ํ ๊ฒฝ์ฐ์๋ ๊ทธ๋ฅ `forEach`๋ฅผ ์ด ๊ฒ ๊ฐ์์
๋์ ์ ๋ ๋ณต์กํ ๊ฒฝ์ฐ์๋ `reduce`๋ฅผ ์ธ ๊ฒ ๊ฐ์์.
`forEach` ๋ณด๋ค ๋ค์ํ ๋ก์ง์ ๋ฃ์(?)์ ์๋ `reduce`์ ํ์ฉ๋ฒ์ด ๋ ๋ง์ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,141 @@
+## ๐ ๊ตฌํ ๋์
+
+### ํฌ๋ฆฌ์ค๋ง์ค ํ๋ก๋ชจ์
+
+### - ๋ชฉํ
+
+=> ์ ์ฐ์ฑ๊ณผ ํ์ฅ์ฑ์ ๊ฐ์กฐํ 12์ ์ด๋ฒคํธ ํ๋๋๋ฅผ ๊ฐ๋ฐํ์ฌ ๋ณํ์ ๋์ํ๊ณ , ๊ฐ์ฒด์งํฅ์ ์ฅ์ ์ ์ต๋ํ ํ์ฉํ๋ค.
+์ค์์ฒ๋ฆฌ์ ์์คํ
์ด ์๋ ๊ฐ์ฒด ๊ฐ์ ํ๋ ฅ์ ๊ฐ์กฐํ์ฌ '์ด์์๋' ์์คํ
์ ์ค๊ณํ๊ณ ,
+๋ชจ๋ ๋๋ฉ์ธ ๋ก์ง์ ์ฒ ์ ํ ๋จ์ ํ
์คํธ๋ฅผ ๋์
ํ์ฌ ์์คํ
์ ๋ฌด๊ฒฐ์ฑ์ ๋ณด์ฅํ๋ค.
+์ด๋ฅผ ํตํด ํ์ฅ์ฑ ์๊ณ ์ ์ง๋ณด์๊ฐ ์ฉ์ดํ ํจ๊ณผ์ ์ธ ์ด๋ฒคํธ ํ๋๋๋ฅผ ๊ตฌ์ถํ๋ค.
+
+### - ์ธ๋ถ ๋ชฉํ ๋ฐ ์ง์นจ
+
+- ํด๋์ค๋ณด๋ค๋ ๋ฉ์์ง ์ค์ฌ ์ค๊ณ
+- UI๋ ๋๋ฉ... | Unknown | ์ด๋ค ๋ถ๋ถ์ ๊ณ ๋ฏผํ๊ณ ๊ตฌํํ์
จ๋์ง ๋ณด๊ธฐ ํธํด์ ์ข๋ค์ ๐๐ |
@@ -0,0 +1,54 @@
+package christmas.controller;
+
+import christmas.domain.entity.Day;
+import christmas.domain.entity.Order;
+import christmas.view.InputView;
+import java.util.function.Supplier;
+
+import static christmas.domain.verifier.RuntimeVerifier.RUNTIME_VERIFIER;
+import static christmas.system.IOMessage.ORDE... | Java | renderResult()๋ฅผ ๋ฐ๋ก ๋ฉ์๋๋ก ๋นผ์ ์ด์ ๊ฐ ์์ผ์ค๊น์? |
@@ -0,0 +1,54 @@
+package christmas.controller;
+
+import christmas.domain.entity.Day;
+import christmas.domain.entity.Order;
+import christmas.view.InputView;
+import java.util.function.Supplier;
+
+import static christmas.domain.verifier.RuntimeVerifier.RUNTIME_VERIFIER;
+import static christmas.system.IOMessage.ORDE... | Java | outputView๋ฅผ static์ผ๋ก ํ์ ์ด์ ๊ฐ ์์ผ์ค๊น์? |
@@ -0,0 +1,54 @@
+package christmas.controller;
+
+import christmas.domain.entity.Day;
+import christmas.domain.entity.Order;
+import christmas.view.InputView;
+import java.util.function.Supplier;
+
+import static christmas.domain.verifier.RuntimeVerifier.RUNTIME_VERIFIER;
+import static christmas.system.IOMessage.ORDE... | Java | static import๋ฅผ ํ์ค ๋๋ ์ด๋ค ๊ฒ๋ค์ importํ๋์ง ์ ๋ํ๋ ์ ์๋๋ก ์์ผ๋์นด๋(*)๋ฅผ ์ฌ์ฉํ์ง์๊ณ ์ ๋ถ ํ์ํ๋ ๊ฒ์ ์ถ์ฒํ๋๋ผ๊ตฌ์.
์ฐธ๊ณ ํ์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,32 @@
+package christmas.controller;
+
+import christmas.domain.entity.Day;
+import christmas.domain.entity.DiscountRecord;
+import christmas.domain.entity.Order;
+import christmas.domain.manager.BonusEventManager;
+import christmas.domain.manager.DiscountManager;
+
+import static christmas.domain.entity.Eve... | Java | ์ ๋ ์ปจํธ๋กค๋ฌ๋ฅผ ์ฌ๋ฌ๊ฐ์ง๋ก ๋๋ ๋ณด๋ ค๊ณ ํ์ด์ ๋ฐ๊ฐ๋ค์!
์ด๋ค ๊ธฐ์ค์ผ๋ก ๋๋ ๋ณด๋ ค๊ณ ํ์
จ๋์ง ๊ถ๊ธํด์ |
@@ -0,0 +1,48 @@
+package christmas.domain.entity;
+
+import christmas.domain.util.Util;
+
+import java.util.Arrays;
+
+import static christmas.system.IOMessage.EMPTY_STRING;
+import static christmas.system.IOMessage.QUANTITY_UNIT;
+
+public enum BonusMenu {
+ CHAMPAGNE(Menu.CHAMPAGNE, 1);
+
+ private final Menu ... | Java | ์ด๋ถ๋ถ์ ์ถ๋ ฅ ๋ถ๋ถ๊ณผ ๊ด๊ณ ์์ด์ OutputView๊ฐ ์ผํ๊ฒ ํ๋ ๊ฒ์ ์ด๋จ๊น์? |
@@ -0,0 +1,65 @@
+package christmas.domain.manager;
+
+
+import christmas.domain.entity.Day;
+import christmas.domain.entity.Order;
+
+import static christmas.domain.entity.MenuType.*;
+import static christmas.system.Constant.ZERO;
+
+public class DiscountManager {
+
+ private final int DISCOUNT_AMOUNT = 2023;
+ ... | Java | day ๊ฐ์ฒด์ ํด๋น ๋ฉ์๋๋ฅผ ๋ฃ์ด๋์ผ๋ ์ฝ๊ธฐ๋ ๋งค์ฐ ํธํด์ ์ข๋ค์ ๐๐ |
@@ -0,0 +1,12 @@
+package christmas.domain.util;
+
+
+import java.text.DecimalFormat;
+
+public final class Util {
+ public static String createFormattedAmount(int target) {
+ DecimalFormat formatter = new DecimalFormat("###,##0");
+ return formatter.format(target);
+ }
+
+} | Java | split ํ๋ ๊ธฐ์ค์ด ๋์ค์๋ ๋ฌ๋ผ์ง ์ ์์ผ๋ ์์๋ก ๋ง๋ค์ด ๊ด๋ฆฌํ๋ฉด ๋์ค์ ์ ์ง๋ณด์ํ๊ธฐ ์ข์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,54 @@
+package christmas.controller;
+
+import christmas.domain.entity.Day;
+import christmas.domain.entity.Order;
+import christmas.view.InputView;
+import java.util.function.Supplier;
+
+import static christmas.domain.verifier.RuntimeVerifier.RUNTIME_VERIFIER;
+import static christmas.system.IOMessage.ORDE... | Java | ์ฌ์ค ์ด๊ฒ system. run()์ ์ฌ๋ฌ ๊ธฐ๋ฅ์ค์ ํ๋๊ฐ renderResult()์ด๋ผ๊ณ ์๊ฐํด์ ๋บ์ด์!. ๋์ค์ ํ์ฅ์ฑ์๊ฒ ๋ค๋ฅธ ๊ธฐ๋ฅ๋ค๋ ๋ฃ์์ ์๊ฒํ๊ธฐ ์ํด์์! |
@@ -0,0 +1,27 @@
+package christmas.system;
+
+public final class IOMessage {
+ public static final String VISIT_DATE_PROMPT_MESSAGE = "์๋
ํ์ธ์! ์ฐํ
์ฝ ์๋น 12์ ์ด๋ฒคํธ ํ๋๋์
๋๋ค.\n" +
+ "12์ ์ค ์๋น ์์ ๋ฐฉ๋ฌธ ๋ ์ง๋ ์ธ์ ์ธ๊ฐ์? (์ซ์๋ง ์
๋ ฅํด ์ฃผ์ธ์!)";
+
+ public static final String ORDER_PROMPT_MESSAGE = "์ฃผ๋ฌธํ์ค ๋ฉ๋ด๋ฅผ ๋ฉ๋ด์ ๊ฐ์๋ฅผ ์๋ ค ์ฃผ์ธ์. (e.g. ... | Java | ์์ฑ์๋ฅผ `private`์ผ๋ก ๋ง์๋์ ๋ชจ์ต์ด ๋ณด๊ธฐ ์ข์ต๋๋ค! ๐ |
@@ -0,0 +1,54 @@
+package christmas.controller;
+
+import christmas.domain.entity.Day;
+import christmas.domain.entity.Order;
+import christmas.view.InputView;
+import java.util.function.Supplier;
+
+import static christmas.domain.verifier.RuntimeVerifier.RUNTIME_VERIFIER;
+import static christmas.system.IOMessage.ORDE... | Java | static์ด ์๋๊ฒ ๊ตฌํํด์ ์์กด๊ด๊ณ๋ฅผ ๊ฐ์ง๊ฒ ํด์ผํ ๊น ๊ณ ๋ฏผํด๋ดค์ต๋๋ค. ํ์คํ ์์กด์ฑ ์ฃผ์
์ด ํ์ํ ๊ด๊ณ์ด๋ค ์ถ์๊ฑฐ๋ ์ฃผ์
์ ์์ผฐ๋๋ฐ inputview์ outputview๊น์ง ์์ผ์ผํ๋ ํด์์. ์ํค๋๊ฒ ๋ง์๊น์? |
@@ -0,0 +1,54 @@
+package christmas.controller;
+
+import christmas.domain.entity.Day;
+import christmas.domain.entity.Order;
+import christmas.view.InputView;
+import java.util.function.Supplier;
+
+import static christmas.domain.verifier.RuntimeVerifier.RUNTIME_VERIFIER;
+import static christmas.system.IOMessage.ORDE... | Java | ํ ๋ชฐ๋์ต๋๋ค. ๊ฐ์ฌํฉ๋๋ค.!! |
@@ -0,0 +1,32 @@
+package christmas.controller;
+
+import christmas.domain.entity.Day;
+import christmas.domain.entity.DiscountRecord;
+import christmas.domain.entity.Order;
+import christmas.domain.manager.BonusEventManager;
+import christmas.domain.manager.DiscountManager;
+
+import static christmas.domain.entity.Eve... | Java | ์ด๊ฒ ์ฌ๋ฌ๊ฐ์ง๋ก ๋๋ ๋ณผ๋ ค๊ณ ํ๋๋ฐ ๋๋ฌด ์ด๋ ต๋๋ผ๊ตฌ์... ๋๋ ์ผ ๊น๋ํ ๊ฑฐ ๊ฐ๊ธฐ๋ ํ๋ฐ...
๊ทธ๋ฅ ์ ํฌ๊ฐ plannerSystem์ ๊ตฌํํ๋๊ฑฐ์๊ณ , ๊ธฐ๋ฅ๋ค์ด ๋ค ์ ์ฐ(๊ธ์ต)๊ณผ ๊ด๋ จ๋ ๋ถ๋ถ์ด๋ผ์ settlementSystem์ ๋์์ต๋๋ค. |
@@ -0,0 +1,76 @@
+package christmas.domain.entity;
+
+import static christmas.domain.verifier.VisitDateVerifier.VISIT_DATE_VERIFIER;
+import static christmas.system.Constant.CHRISTMAS;
+import static christmas.system.Constant.FIRST_DAY_OF_MONTH;
+
+public class Day {
+
+ private static final int WEEK_LENGTH = 7;
+ ... | Java | ๋ฉ์๋๋ช
์ ์ ๋ง ์ ์ง์ผ์ ๊ฑฐ ๊ฐ์์! ๐ |
@@ -0,0 +1,48 @@
+package christmas.domain.entity;
+
+import christmas.domain.util.Util;
+
+import java.util.Arrays;
+
+import static christmas.system.IOMessage.EMPTY_STRING;
+import static christmas.system.IOMessage.QUANTITY_UNIT;
+
+public enum BonusMenu {
+ CHAMPAGNE(Menu.CHAMPAGNE, 1);
+
+ private final Menu ... | Java | ์ฒ์์๋ ๊ทธ๋ฐ ๋ฐฉ์์ผ๋ก ํ์๋๋ฐ,
๊ฐ ํด๋์ค์์, ํด๋์ค์ ๋ํด ์ถ๋ ฅํ ์ ๋ณด๋ฅผ ๋ง๋๋๊ฑฐ๊น์ง๋ ๊ฐ์ฒด๊ฐ ๋ด๋นํด์ผํ ๋ชซ์ด์ง ์์๊น ํด์ ๋ฐ๊ฟจ์์ด์...
์ถ๋ ฅ์ outputview์์ ํฉ๋๋ค. ์ด ๋ถ๋ถ์ ๋ค๋ฅธ๋ถ๋ถ์ ์๊ฒฌ๋ ๋ฃ๊ณ ์ถ์ด์!!
1. outputview์์ getter๊ฐ ์๋๋๋ผ๋, ์ธ์๋ฅผ ํตํด ์ถ๋ ฅํ ํด๋์ค์ ์ ๋ณด๋ฅผ ๊บผ๋ด์ ์ถ๋ ฅ ๋ฉ์์ง๋ฅผ ๋ง๋ค๊ณ ์ถ๋ ฅ๊น์ง ํ๋๊ฑธ ๋ด๋นํด์ผํ ๊น?
2. ์ถ๋ ฅํด์ผํ ํด๋์ค์ ์ ๋ณด๋ ํด๋์ค ๋ด์์ ๋ง๋ค๊ณ , ์ถ๋ ฅ๋ง outputview์์ ํด์ผํ๋๊ฒ ๋ง์๊น์? |
@@ -0,0 +1,12 @@
+package christmas.domain.util;
+
+
+import java.text.DecimalFormat;
+
+public final class Util {
+ public static String createFormattedAmount(int target) {
+ DecimalFormat formatter = new DecimalFormat("###,##0");
+ return formatter.format(target);
+ }
+
+} | Java | ์ฐธ๊ณ ํ๊ฒ ์ต๋๋ค. ๋๋ฌด๋๋ฌด ํผ๋๋ฐฑ ์ด์ฌํ ํด์ฃผ์
์ ๊ฐ์ฌํด์ ์์ฌ๋ ๐ |
@@ -0,0 +1,76 @@
+package christmas.domain.entity;
+
+import static christmas.domain.verifier.VisitDateVerifier.VISIT_DATE_VERIFIER;
+import static christmas.system.Constant.CHRISTMAS;
+import static christmas.system.Constant.FIRST_DAY_OF_MONTH;
+
+public class Day {
+
+ private static final int WEEK_LENGTH = 7;
+ ... | Java | ๊ฐ์ธ์ ์ธ ์๊ฒฌ์ธ๋ฐ, `isFriday() || isSaturday()`๊ฐ `isWeekend()`๋ฉ์๋์ ๋๊ฐ์ผ๋, ์ด๊ฑธ ํ์ฉํ๋๊ฒ ์ด๋จ๊น์?
```java
public boolean isWeekday() {
return !isWeekend();
}
```
์ด๋ ๊ฒ์! ๐ |
@@ -0,0 +1,59 @@
+package christmas.domain.entity;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static christmas.domain.entity.MenuType.*;
+
+public enum Menu {
+
+ MUSHROOM_SOUP("์์ก์ด์ํ", 6_000, APPETIZER),
+ TAPAS("ํํ์ค", 5_500, APPETIZER),
+ CAESAR_SALAD("์์ ์๋ฌ๋", 8_000, APPETIZER),
+
+ T_B... | Java | ๋ฐ๋ก `HashMap`์ ๋ง๋ค์ด ๋ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค! `getMenuItemByName`๋ฉ์๋์์ ๊ฒ์์๋๋ฅผ ๋์ด๊ธฐ ์ํจ์ธ๊ฐ์? |
@@ -0,0 +1,12 @@
+package christmas.domain.util;
+
+
+import java.text.DecimalFormat;
+
+public final class Util {
+ public static String createFormattedAmount(int target) {
+ DecimalFormat formatter = new DecimalFormat("###,##0");
+ return formatter.format(target);
+ }
+
+} | Java | split์ ํ ๊ฒฐ๊ณผ๊ฐ ์ฌ์ด์ฆ๊ฐ 1์ด์ด์ `orderItemSpec[1]`์ ์ ๊ทผ์ด `IndexOutOfBoundsException`์ ์ผ์ผํฌ ๊ฒฝ์ฐ๋ ์๋์? ์ด๋ฅผ ์ผ๋ํด๋์
จ๋๋ฉด ์ด๋ป๊ฒ ๊ฒ์ฆ์ ํ์
จ๋์ง ๊ถ๊ธํฉ๋๋ค! |
@@ -0,0 +1,96 @@
+package christmas.domain.verifier;
+
+
+import christmas.domain.entity.Menu;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static christmas.system.ExceptionMessage.*;
+
+public class OrderMenuVerifier implements Verifier<S... | Java | ๋ฐ๋ก ์ธ์์ ๋ฐ๋ผ์ ํจํด์ด ๋ฌ๋ผ์ง๋ ๊ฒ ๊ฐ์ง ์์๋ฐ, ํ๋์์ ๋ฐ๋ก ์ด๊ธฐํํ์ง ์๊ณ , ์์ฑ์ ๋ด๋ถ์์ ์ด๊ธฐํํ์ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค! ๋ญ๊ฐ ๋ ์ข์ ๋ฐฉ๋ฒ์ธ์ง ์ ๋ ์ ๋ชจ๋ฅด๊ฒ ์ด์.. ๐ |
@@ -0,0 +1,14 @@
+package christmas.domain.verifier;
+
+public interface Verifier<T> {
+
+ abstract public void validate(T input);
+
+ static void throwIllegalArgumentError(String errorMessage) {
+ throw new IllegalArgumentException(errorMessage);
+ }
+
+ static void throwIllegalStateError(String err... | Java | ์ด ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ ํด๋์ค๋ค์ `check`๋ง ์ฌ์ฉํ๋ฉด ํ์ํ ๊ฒ์ฆ์ด ๋ค ๋๋ ๋ฐฉ์์ด๋ค์! ๊น๋ํ๊ณ ์ข๋ค์! ๐ |
@@ -0,0 +1,59 @@
+package christmas.domain.entity;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static christmas.domain.entity.MenuType.*;
+
+public enum Menu {
+
+ MUSHROOM_SOUP("์์ก์ด์ํ", 6_000, APPETIZER),
+ TAPAS("ํํ์ค", 5_500, APPETIZER),
+ CAESAR_SALAD("์์ ์๋ฌ๋", 8_000, APPETIZER),
+
+ T_B... | Java | ๋ค ๋ง์์! HashMap์ ์ฌ์ฉํ๋ฉด ๊ฒ์์๋๊ฐ O(1)์ ๊ฐ๊น์ด ์๋๋ก ๋งค์ฐ ํฅ์๋๋ค๊ณ ํฉ๋๋ค.!! |
@@ -0,0 +1,96 @@
+package christmas.domain.verifier;
+
+
+import christmas.domain.entity.Menu;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static christmas.system.ExceptionMessage.*;
+
+public class OrderMenuVerifier implements Verifier<S... | Java | ์ ๋ ๋ญ๊ฐ ๋ ์ข์ ๋ฐฉ๋ฒ์ธ์ง ๋ชฐ๋ผ์ ์ฐพ์๋ดค์๋๋ฐ,
์์ฑ์์์ ์ด๊ธฐํ๋ฅผ ํ๋ฉด, ์์ฑ์ ์์ ํจ์์ ๋ํ ์์ธ์ฒ๋ฆฌ๊ฐ ๊ฐ๋ฅํด์ง๊ณ , ์ธ๋ถ์์ ๋ค๋ฅธ pattern๊ฐ์ฒด๋ฅผ ์ฃผ์
ํ๊ธฐ๊ฐ ์ฌ์์ง๋ค๊ณ ํ๋๋ผ๊ตฌ์.
๋ฐ๋ฉด์ ํ๋์์ ์ด๊ธฐํํ๋ฉด ๊ฐ๋
์ฑ๊ณผ ๊ฐ๊ฒฐํจ์ด ์ฅ์ ์ด์ฃ .
์์ฑ์์์์ ์์ธ์ฒ๋ฆฌ ๋ก์ง์ด ์์ง๋ง ์ด๋ ๊ฒ๋ ํ๋ฒ ํด๋ดค์ด์! ์ํฉ์ ๋ฐ๋ผ์ ๋ค๋ฅด๊ฒ ํด๋ณด๋ฉด ์ข์๊ฑฐ ๊ฐ์์!! |
@@ -0,0 +1,14 @@
+package christmas.domain.verifier;
+
+public interface Verifier<T> {
+
+ abstract public void validate(T input);
+
+ static void throwIllegalArgumentError(String errorMessage) {
+ throw new IllegalArgumentException(errorMessage);
+ }
+
+ static void throwIllegalStateError(String err... | Java | ํผ๋๋ฐฑ ์ ๋ง ๊ฐ์ฌํด์! ์ธ์
๋๋ ํฌ๋ฆฌ์ค๋ง์ค ์ฝ๋ ๋ฆฌ๋ทฐ ํด๋๋ฆด๋ ค๊ณ ํ๋๋ฐ repository๊ฐ private์ธ๊ฐ๋ด์๐ |
@@ -0,0 +1,76 @@
+package christmas.domain.entity;
+
+import static christmas.domain.verifier.VisitDateVerifier.VISIT_DATE_VERIFIER;
+import static christmas.system.Constant.CHRISTMAS;
+import static christmas.system.Constant.FIRST_DAY_OF_MONTH;
+
+public class Day {
+
+ private static final int WEEK_LENGTH = 7;
+ ... | Java | ์ค... ๊ฐ์ฌํฉ๋๋ค.! ๋ฆฌํํ ๋ง ํด๋ณผ๊ฒ์ |
@@ -0,0 +1,12 @@
+package christmas.domain.util;
+
+
+import java.text.DecimalFormat;
+
+public final class Util {
+ public static String createFormattedAmount(int target) {
+ DecimalFormat formatter = new DecimalFormat("###,##0");
+ return formatter.format(target);
+ }
+
+} | Java | ์๋ฅผ๋ค์ด,
Input: ์ดํ์ธ-
์ด๋ ๊ฒ ์
๋ ฅ๋ ๊ฒฝ์ฐ, orderMenuVerifier์ checkMenuFormat ๋ฉ์๋์ ์ํด ์ฌ๋ฐ๋ฅธ ๋ฉ๋ด ํ์์ด ์๋ ์์ธ์ฒ๋ฆฌ๊ฐ ๋์ด์ ธ๋ฒ๋ ค
์์ Util๋ฉ์๋๋ฅผ ํธ์ถํ๋ ๊ฒฝ์ฐ๊ฐ ์๋๋ก ๊ตฌํํ์ต๋๋ค.
<img width="474" alt="image" src="https://github.com/Hoo-sung/java-christmas-6-Hoo-sung/assets/121723421/e2a0a147-e665-4a6a-94ce-3876632e0d0b">
์ด๋ ๊ฒ orderMenuVerifier๋ก ๊ฒ์ฆ์ ๋ง์น๊ณ Util cl... |
@@ -0,0 +1,39 @@
+import { getProductListProps } from './product';
+
+interface Props extends getProductListProps {
+ baseUrl: string;
+}
+
+const buildGetProductListURL = ({
+ baseUrl,
+ category,
+ page,
+ size,
+ order,
+}: Props) => {
+ const params = [];
+
+ if (category) {
+ params.push(`category=${enc... | TypeScript | api ๊ด๋ฆฌํ๊ฑฐ ๋ฉ์์ด์... ๐
step2 ๋ ์ ๋ ์ด๋ ๊ฒํด๋ณด๊ณ ์ถ๋ค์!! |
@@ -0,0 +1,47 @@
+import React from 'react';
+import styled from '@emotion/styled';
+import { theme } from '@/style/theme.style';
+
+type ButtonThemeType = 'dark' | 'light' | 'disabled';
+
+const BUTTON_THEME = {
+ dark: {
+ backgroundColor: theme.color.black,
+ color: theme.color.white,
+ },
+ light: {
+ b... | Unknown | styled ์ด๋ ๊ฒ ํ ํ์ผ์ ์ ๋๊ฒ๋ ๊ฐ๋
์ฑ ์ข๋ค์
์ ๋ emotion ์ผ๋๋ฐ ui ์์
ํ๋ฉด์ ๊ณ์ ์๋ฆฌ๊ฐ๋ฆฌํ๋ ๊ฒฝํ์ด์์ด์.. |
@@ -0,0 +1,195 @@
+# https://www.acmicpc.net/problem/9663
+
+# import sys
+# from turtle import width
+# n = int(sys.stdin.readline())
+
+# all_page = [0] * n #์ด
+# a = [False] * n #ํ
+# b = [False] * ((n * 2) - 1) #์ ๋ฐฉํฅ ๋๊ฐ
+# c = [False] * ((n * 2) - 1) #์ญ๋ฐฉํฅ ๋๊ฐ
+
+
+# def queen(n) -> None:
+# first = 0... | Python | ์ ๋ ๋จ์ ๊ฑฐ ์ฐธ๊ณ ํ๊ฑฐ๋ผ ๋ถ๋๋ฝ๋ค์ ใ
์ด์ฐจ์ ๋ฐฐ์ด๋ก ํ๋ค๊ฐ 1์ฐจ์๋ฐฐ์ด๋ก ์ค์ผ ์ ์๋ค๋ ๋ฐ์์ด ์ด๋ ค์ ๋ ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,23 @@
+# https://www.acmicpc.net/problem/1181
+# https://blockdmask.tistory.com/543
+# set์ ์ด์ฉํ๋ฉด ์ค๋ณต์ด ์ ๊ฑฐ๋จ
+# https://always-challenger-lab.tistory.com/22
+# ๋๋ค ์ด์ฉํด์ ๋ค์ค์กฐ๊ฑด ์ ๋ ฌ
+import sys
+
+n = int(sys.stdin.readline())
+s = []
+m = []
+for i in range(n):
+ s.append(str(sys.stdin.readline().strip(... | Python | ๋๋ค ์ฌ์ฉ์ด ์ ๋ฐํค๋ค์ ใ
.ใ
์ฐธ๊ณ ๊ฐ ๋์ต๋๋ค. |
@@ -0,0 +1,54 @@
+const generateBasicToken = (userId: string, userPassword: string): string => {
+ const token = btoa(`${userId}:${userPassword}`);
+ return `Basic ${token}`;
+};
+
+const API_URL = `${import.meta.env.VITE_API_URL}`;
+const USER_ID = `${import.meta.env.VITE_USER_ID}`;
+const USER_PASSWORD = `${import.... | TypeScript | ```
const API_URL = `${import.meta.env.VITE_API_URL}`;
const USER_ID = `${import.meta.env.VITE_USER_ID}`;
const USER_PASSWORD = `${import.meta.env.VITE_USER_PASSWORD}`;
```
์ด ๋ถ๋ถ์ ์์ ํ์ผ์์ ๋ฐ๋ก ๊ด๋ฆฌํด๋ณด๋ ๊ฒ์ ์ด๋จ๊น์?
`API_URL `์ด ์์ด๋ endPoint, fetchWithAuth์์ ๋ ๋ฒ ์ ์ธ๋๋ค์ |
@@ -0,0 +1,123 @@
+import { RULE } from "@constants/rules";
+import {
+ CART_ITEMS_COUNTS_ENDPOINT,
+ CART_ITEMS_ENDPOINT,
+ PRODUCTS_ENDPOINT,
+} from "./endpoints";
+import { fetchWithAuth } from "./fetchWithAuth";
+
+/**
+ * @example
+ * const params: QueryParams = {
+ * category: 'fashion',
+ * page: 1,
+ * s... | TypeScript | ์์ฒญํด์ผํ๋ api ๊ฐ ๋ง์์ง๋ค๋ฉด, api/index.ts ์ฝ๋๊ฐ ๋ง์์ง๊ฒ ๋ค์.
๊ด๋ จ์๋ api ์์ฒญ ๋ผ๋ฆฌ ๋ฌถ์ด์ ํ์ผ๋ก ๊ด๋ฆฌํ๊ณ , index.ts์์ ํด๋น ํ์ผ๋ค์ api ์์ฒญ ๋ฉ์๋๋ฅผ export ํ๋ ๊ฒ์ ์ด๋จ๊น์?
```dash
api
ใด cart
ใด products
ใด index
``` |
@@ -0,0 +1,61 @@
+import { forwardRef, useContext } from "react";
+import * as PI from "./ProductItem.style";
+import CartControlButton from "../../Button/CartControlButton";
+import { deleteProductInCart, postProductInCart } from "@api/index";
+import { useError } from "@hooks/index";
+import { CartItemsContext } from... | Unknown | ์ฅ๋ฐ๊ตฌ๋์ ๋ด๋ ๋ก์ง๊ณผ ๋นผ๋ ๋ก์ง์ ํจ์๋ก ๋ถ๋ฆฌํ๊ณ ,
if else๋์ early return ์ ์ฌ์ฉํด๋ณด๋ ๊ฒ์ ์ด๋จ๊น์? |
@@ -0,0 +1,61 @@
+import { forwardRef, useContext } from "react";
+import * as PI from "./ProductItem.style";
+import CartControlButton from "../../Button/CartControlButton";
+import { deleteProductInCart, postProductInCart } from "@api/index";
+import { useError } from "@hooks/index";
+import { CartItemsContext } from... | Unknown | alt์ ๋ํด์ ์ ๋ฒ ๋ฏธ์
์์ ํ๋ฃจ์๊ฒ ๋ฐ์ ํผ๋๋ฐฑ์ ๊ณต์ ํ ๊ฒ์.
image์ alt๋ 'ํฐ ์ด๋ํ์ ๊ฒ์์ ์ค์ด ํ๋ ๋ค์ด๊ฐ ์๋๋ค์ค ์ด๋ํ'์ฒ๋ผ ํด๋น ์ด๋ฏธ์ง์ ๋ํ ๊ตฌ์ฒด์ ์ธ ์ค๋ช
์ด ๋ค์ด๊ฐ์ผํด์.
ํ์ง๋ง ํ์ฌ ์๋ฒ์์ ์ฃผ๋ ์์ธํ ์ํ ์ค๋ช
์ด ์๋ ์ํฉ์์๋`alt=''"`๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข๋ค๊ณ ํ๋ค์.
alt๋ฅผ ์ฌ์ฉํ์ง ์๋ ๊ฒ๊ณผ alt์ ๋น๋ฌธ์์ด๋ก ๋๋ ๊ฒ์ ์ฐจ์ด๋ฅผ ๊ณต๋ถํด๋ณธ๋ค๋ฉด, ์ํ์๊ฒ ๋์์ด ๋ ๊ฑฐ์์. ๐ |
@@ -0,0 +1,44 @@
+import { FILTER_CATEGORIES, SORT_PRICE } from "@constants/rules";
+import * as PLH from "./ProductListHeader.style";
+
+interface ProductListHeaderProps {
+ handleCategory: (category: Category) => void;
+ handleSort: (sort: Sort) => void;
+}
+
+const ProductListHeader = ({
+ handleCategory,
+ hand... | Unknown | selectbox ๋ ๋ค name,id๋ฅผ ๋น๋ฌธ์์ด๋ก ๋ ์ด์ ๊ฐ ์์๊น์? |
@@ -0,0 +1,44 @@
+import { FILTER_CATEGORIES, SORT_PRICE } from "@constants/rules";
+import * as PLH from "./ProductListHeader.style";
+
+interface ProductListHeaderProps {
+ handleCategory: (category: Category) => void;
+ handleSort: (sort: Sort) => void;
+}
+
+const ProductListHeader = ({
+ handleCategory,
+ hand... | Unknown | selectbox๋ฅผ ํ๋์ ์ปดํฌ๋ํธ๋ก ๋ถ๋ฆฌํด๋ ์ข์ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,54 @@
+const generateBasicToken = (userId: string, userPassword: string): string => {
+ const token = btoa(`${userId}:${userPassword}`);
+ return `Basic ${token}`;
+};
+
+const API_URL = `${import.meta.env.VITE_API_URL}`;
+const USER_ID = `${import.meta.env.VITE_USER_ID}`;
+const USER_PASSWORD = `${import.... | TypeScript | ์ค, ๋ฐ๋ก ์ ๊ทน ๋ฐ์ ํ๊ฒ ์ต๋๋ค! |
@@ -0,0 +1,61 @@
+import { forwardRef, useContext } from "react";
+import * as PI from "./ProductItem.style";
+import CartControlButton from "../../Button/CartControlButton";
+import { deleteProductInCart, postProductInCart } from "@api/index";
+import { useError } from "@hooks/index";
+import { CartItemsContext } from... | Unknown | ์ง์ง ์ ์ฑ์ด๋ฆฐ ๋ต๋ณ ์ต๊ณ .. |
@@ -0,0 +1,44 @@
+import { FILTER_CATEGORIES, SORT_PRICE } from "@constants/rules";
+import * as PLH from "./ProductListHeader.style";
+
+interface ProductListHeaderProps {
+ handleCategory: (category: Category) => void;
+ handleSort: (sort: Sort) => void;
+}
+
+const ProductListHeader = ({
+ handleCategory,
+ hand... | Unknown | ์.. ๊ทธ๊ฒ์ ๋ฏธ์ฒ ์์ฑํ์ง ๋ชปํ ์ ์ ์ค์.. |
@@ -0,0 +1,44 @@
+import { FILTER_CATEGORIES, SORT_PRICE } from "@constants/rules";
+import * as PLH from "./ProductListHeader.style";
+
+interface ProductListHeaderProps {
+ handleCategory: (category: Category) => void;
+ handleSort: (sort: Sort) => void;
+}
+
+const ProductListHeader = ({
+ handleCategory,
+ hand... | Unknown | ๋ฐ๋ก ๋ถ๋ฆฌํ ๊น ๊ณ ๋ฏผํ์๋๋ฐ, ์๊ฒฌ์ด ๋ค์ด์์ผ๋ ๋ถ๋ฆฌํด๋ณด๊ฒ ์ต๋๋ค! |
@@ -0,0 +1,9 @@
+package com.codesquad.baseballgame.domain.game.controller;
+
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class GameController {
+
+
+} | Java | ์. ์ด๋ฐ ์ปจํธ๋กค๋ฌ๋ ์ฐ์ง ์๋๋ค๋ฉด ๊ทธ๋๊ทธ๋ ์ง์์ฃผ๋ ๊ฒ์ด ์ข๊ฒ ์ต๋๋ค. |
@@ -0,0 +1,24 @@
+package com.codesquad.baseballgame.domain.game.controller;
+
+import com.codesquad.baseballgame.domain.game.service.MatchService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.a... | Java | ์ค๊ณํ๊ธฐ ๋๋ฆ์ด๊ธด ํ์ง๋ง, `@PathVariable` ๋ง์ ํ๋ผ๋ฏธํฐ๋ก ๋ฐ๋ ์๋ํฌ์ธํธ์์ `POST` ๋ฅผ ์ฐ๋๊ฑด ๋ค์ ์ด์ํด๋ณด์ด๊ธด ํ๋ค์.
๋ญ๊ฐ๊ฐ ๋๋ฝ๋ ๊ฑด ์๋๊ฐ์. ๋ฆฌํด ๋ฐ๋์ `true` `false` ๋ง์ ์ฃ๋ ๊ฒ๋ ์ข ์ด์ํฉ๋๋ค. |
@@ -0,0 +1,7 @@
+package com.codesquad.baseballgame.domain.game.dao;
+
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class GameDao {
+} | Java | ์ ์ฌ๊ธฐ๋ ๋น์ด์๊ตฐ์? |
@@ -0,0 +1,14 @@
+package com.codesquad.baseballgame.domain.game.dto;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.ToString;
+
+@Getter @ToString
+@RequiredArgsConstructor
+public class BallCountDto {
+
+ private int strike;
+ private int ball;
+ private int out;
+} | Java | ์ ๋
ธํ
์ด์
์ ํ ์ค์ ํ๋๋ฅผ ์ฐ๋ ๊ฒ์ ์์น์ผ๋ก ํด ์ฃผ์ธ์.
```suggestion
@Getter
@ToString |
@@ -0,0 +1,14 @@
+package com.codesquad.baseballgame.domain.game.dto;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.ToString;
+
+@Getter @ToString
+@RequiredArgsConstructor
+public class BallCountDto {
+
+ private int strike;
+ private int ball;
+ private int out;
+} | Java | ์์ฑ์๊ฐ ์ํ๋ ๋๋ก ์์ฑ๋์๋์?
์ ๊ฐ ์๊ธฐ๋ก ์ด ์ ๋
ธํ
์ด์
์ `final` ํ๋์ ๋ํด์๋ง ์์ฑ์๋ฅผ ๋ง๋๋๋ฐ์.
์๋ ์ด๋ค ํ๋๋ `final` ์์ฝ์ด๋ฅผ ๊ฐ์ง ์๋ค์. |
@@ -0,0 +1,10 @@
+package com.codesquad.baseballgame.domain.game.service;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class GameService {
+
+
+
+} | Java | ์ ์ด๋ ๊ฒ ๋น์ด์๋ ํด๋์ค๋ค์ด ๋ง์๊ฑฐ์ฃ ... |
@@ -0,0 +1,23 @@
+package com.codesquad.baseballgame.domain.game.service;
+
+import com.codesquad.baseballgame.domain.team.dao.TeamDao;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transa... | Java | `SERIALIZABLE` ์ ๋ง ๊ด์ฐฎ์๊น์? ์ ํํ ์ดํดํ๊ณ ์ฌ์ฉํ์ ๊ฑด๊ฐ์.
๋๋ถ๋ถ์ ๊ฒฝ์ฐ `SERIALIZABLE` ๊น์ง ๊ณ ๋ฆฝ์์ผ์ผ ํ ํธ๋์ญ์
์ ์์ต๋๋ค.
์ ํ๋ฆฌ์ผ์ด์
๋ ์ด์ด์์ ์ด๋ฐ ์์ค์ ๊ณ ๋ฆฝ์ด ํ์ํ ๊ฒฝ์ฐ, ์ ํ๋ฆฌ์ผ์ด์
๋ก์ง์ ๋ค์ ๊ฒํ ํด์ ์ ๋ง ์ด์ ๋์ ํธ๋์ญ์
์ด ํ์ํ์ง ์ดํด๋ณด๊ณ ,
์ ๋ง ๊ณ ๋ฆฝ ์์ค ์กฐ์ ์ด ํ์ํ ๊ฒฝ์ฐ์๋, ์ฌ์ค์ ๊ณ ๋ฆฝ ์์ค ์กฐ์ ์ด ์๋๋ผ propagation ์ ๋ต ์์ ์ผ๋ก ๋์ํ ์ ์์ง๋ ์์์ง ๋ค์ ํ ๋ฒ ์๊ฐํด๋ด์ผ ํฉ๋๋ค.
์๋ง ๊ฐฏ์๋ฅผ ์ธ๋ ์ฟผ๋ฆฌ๊ฐ ์๋ค๋ณด๋ ์ฟผ๋ฆฌ๊ฐ ๋๋ ๋์ ์๋ก์ด ์ปค๋ฐ์ด ์ผ์ด๋์ ๊ฒฐ๊ณผ๊ฐ ๋ค๋ฐ๋๋ ์ผ... |
@@ -0,0 +1,23 @@
+package com.codesquad.baseballgame.domain.game.service;
+
+import com.codesquad.baseballgame.domain.team.dao.TeamDao;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transa... | Java | `@Transactional` ์ด ์ ์ธ๋ ๋ฉ์๋์์ ์ด๋ ๊ฒ ๋ฉ์๋๋ฅผ ํธ์ถํ๋ฉด, ํธ๋์ญ์
์ด ์ ์ฉ๋์ง ์์ต๋๋ค.
https://mommoo.tistory.com/92 |
@@ -0,0 +1,20 @@
+package com.codesquad.baseballgame.domain.hitter.mapper;
+
+import com.codesquad.baseballgame.domain.hitter.dto.HitterListDto;
+import org.springframework.jdbc.core.RowMapper;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class HitterListMapper implements RowMapper<HitterListD... | Java | `RowMapper` ์์ ๋ฐ๋ก DTO๋ก ๋งคํํ๋ค์.
๋ชจ๋ธ ํด๋์ค๊ฐ ํ๋ ์๋๊ฒ ์ข๊ธด ํ๋ฐ... ๋ชจ๋ธ ํด๋์ค์ ํ์์ฑ์ด ์์๋๋ณด๋ค์. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.