code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -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,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,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๋ก ๋งคํํ๋ค์.
๋ชจ๋ธ ํด๋์ค๊ฐ ํ๋ ์๋๊ฒ ์ข๊ธด ํ๋ฐ... ๋ชจ๋ธ ํด๋์ค์ ํ์์ฑ์ด ์์๋๋ณด๋ค์. |
@@ -0,0 +1,15 @@
+package com.codesquad.baseballgame.domain.scoreboard.controller;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class ScoreBoardContro... | Java | ์...... |
@@ -0,0 +1,23 @@
+package com.codesquad.baseballgame.domain.scoreboard.dao;
+
+import com.codesquad.baseballgame.domain.scoreboard.dto.ScoreBoardInningDto;
+import com.codesquad.baseballgame.domain.team.mapper.TeamDtoMapper;
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
+import org.spring... | Java | ์ฃผ์์ ์ง์์ฃผ์ธ์. |
@@ -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 | ์ฐ๋ฉด์ ์๋ฟ์ธ.. ํ๊ณ ๋๋์ ์์๋๋ฐ.. ๋ง์ง๋ง์ ๋ง๋๋๋ผ ๊ธฐ๋ณธ ๋ฒ์น์ ์๊ณ ๋ง ๋ง๋ ๊ฒ ์์ธ์ด์์ต๋๋ค. ๊ธํ๋๋ผ๋ ์งํฌ๊ฑด ์งํค๋ฉด์ ๋ง๋ค์ด์ผํ๋๋ฐ ์ ๊ฐ ๋๋ฌด ์๋๋ ๋ค์. ์ต์ํ์ Json์ ๋ง๋ค์์ด์ผํ๋๋ฐ ๋ค์์๋ ์งํค๋๋ก ํ๊ฒ ์ต๋๋ค. |
@@ -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 | ์ฌ๋ฌ์๊ฐ ํ๋ฉด์ ์ฝ๋ฉํ๋ค๊ฐ ์๋ฌด๊ฑฐ๋ ๋ค ๋ฃ๋๋ฐ๋์ ์๊ธด ๋ฌธ์ ์
๋๋ค. ๊ธฐ๋ฅ ํ๋๋ง๋ค ๋ ๊ทธ๋ ์ง์คํ์ด์ผ ํ๋๋ฐ ์ด๊ฒ ์ ๊ฒํ๋ค๊ฐ ์ด๋์ ๋ ์๋๊ฒ ๋์์ต๋๋ค. ์ ๊ฐ ์ด๊ฑธ ๋ฃ์๋ค๋๊ฒ๋ ์ง๊ธ ์์๋ค์. Dto ์์ ๋ฃ์ ์๊ฐ ์์๋๋ฐ.... ์ด๋ฒ ๊ธฐํ๋ก ์ ์ ๋๋ฐ๋ก ์ฐจ๋ ค์ผ๊ฒ ์ต๋๋ค |
@@ -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 | ํธ๋์ ์
์ ๋ํ ๋ด์ฉ์ ๋ธ๋ก๊ทธ์์ ๊ฐ๋ณ๊ฒ ๋ณด๊ณ ์ด ๋ ์ฐ๋๊ฑด๊ฐ ํ๊ณ ์ผ๋๋ฐ ์ข ๋ ๊ณต๋ถ๊ฐ ํ์ํ๋๊ตฐ์. Read Committed ์ ๋ํด์ ์กฐ์ฌํ๊ฒ ์ต๋๋ค. |
@@ -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 | ๋ชจ๋ธ ํด๋์ค์ ํ์์ฑ์ด ์์๋ค๊ธฐ๋ณด๋จ ์ค๊ณ๊ฐ ์๋ชป๋์์ต๋๋ค. ๋ง์ฝ ๋ชจ๋ธํด๋์ค์ ๋ง๊ฒ ํ๋ค๋ฉด ์ง๊ธ๋ณด๋ค ๋์ฑ ๋น ๋ฅด๊ฒ ์ฝ๋ฉ์ด ๋์์ํ
๋ฐ ์์ฝ์ต๋๋ค. ์ค๊ณ๋ฅผ ๊ผญ ์ ๋๋ก ๋ง์ถฐ์ผ๊ฒ ๋ค์ |
@@ -0,0 +1,23 @@
+package com.codesquad.baseballgame.domain.scoreboard.dao;
+
+import com.codesquad.baseballgame.domain.scoreboard.dto.ScoreBoardInningDto;
+import com.codesquad.baseballgame.domain.team.mapper.TeamDtoMapper;
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
+import org.spring... | Java | ๋ต |
@@ -0,0 +1,15 @@
+package com.codesquad.baseballgame.domain.scoreboard.controller;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class ScoreBoardContro... | 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 | ํธ๋์ ์
์ ๋ํด์ ํ์คํ๊ฒ ๊ณต๋ถํด์ผ๊ฒ ๋ค์. ์ด์คํ ์ฌ์ฉ์ ์ง์ํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค. |
@@ -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 | ์ ์ค๋ ์ ํํ๊ฒ ์์
์ ํ๋๊ตฐ์ ๋ฆฌ๋ทฐ๋ณด์๋ง์ ์์
์ ํ๋ ๊ธฐ์ฉ๋๋ค. Repeatable Read๋ก๋ง ์ปค๋ฒ๊ฐ ๊ฐ๋ฅํ๋ค์ |
@@ -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,28 @@
+package christmas.util;
+
+public class DateValidator {
+ private static final String INVALID_DATE_MESSAGE = "์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.";
+
+ public static void validateInput(String input) {
+ validateNumeric(input);
+ int date = Integer.parseInt(input);
+ validateDate(date... | Java | 31์ผ๋ก ๋๋์ง ์๋ ๋ฌ๋ ์๊ธฐ๋๋ฌธ์ 12์์ ๋ํ ์์กด์ฑ์ ์ฃผ์
๋ฐ์์ ํด๋นํ๋ ์(ๆ)์ ๋ง์ถฐ ์ต๋ ์ผ์๋ฅผ ๋ณ๊ฒฝ ํ๋์ง ํด๋น ์ด๋ฒคํธ์ ๋ํ ์์๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ ๊ทธ ์ธ ๋ค์ํ ๋ฐฉ์์ผ๋ก ์กฐ๊ฑด์ ์กฐ์ ํ๋ ๊ฒ๋ ์ข์๊ฑฐ๋ผ ์๊ฐํฉ๋๋ค! |
@@ -0,0 +1,103 @@
+package christmas.util;
+
+import christmas.domain.type.Menu;
+
+import java.util.*;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+public class OrderValidator {
+ private static final String LINE_SEPARATOR = System.lineSeparator();
+
+ private static final int MIN_AMO... | Java | ์ ๊ท์์ ์ฌ์ฉํ ๋ ๋ฏธ๋ฆฌ ์บ์ฑํ๋ ๋ฐฉ๋ฒ์ด ์๋ค๊ณ ํฉ๋๋ค!
https://mntdev.tistory.com/69#%F0%9F%91%8D%20%EC%A0%95%EC%A0%81%20%ED%8C%A9%ED%84%B0%EB%A6%AC%EB%A5%BC%20%EC%A0%9C%EA%B3%B5%ED%95%98%EB%8A%94%20%EB%B6%88%EB%B3%80%20%ED%81%B4%EB%9E%98%EC%8A%A4-1
์ด ๊ธ์ ํ๋ฒ ์ฐธ๊ณ ํด๋ณด์๋ฉด ์ข์ ๊ฒ๊ฐ์์! ๐ |
@@ -0,0 +1,103 @@
+package christmas.util;
+
+import christmas.domain.type.Menu;
+
+import java.util.*;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+public class OrderValidator {
+ private static final String LINE_SEPARATOR = System.lineSeparator();
+
+ private static final int MIN_AMO... | Java | "," ๋ "-"๋ ์์๋ก ๊ด๋ฆฌํ๋ฉด ์ข์ ๊ฒ ๊ฐ์์! ์ด๋ฒคํธ์ ๋ฐ๋ผ ์
๋ ฅ๋ฐ๋ ๋ฐฉ์์ด ๋ฐ๋ ์๋ ์์์์ ๐ |
@@ -0,0 +1,76 @@
+package christmas.domain.logic;
+
+import christmas.domain.type.Badge;
+import christmas.domain.type.Menu;
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+public class EventCalculatorTest {
+
+ @Test
+ void isEligibleForEvent()... | Java | ํด๋ฆฐ์ฝ๋์ ๋์ค๋ ๋ด์ฉ์ธ๋ฐ ํ ํ
์คํธ ๋ฉ์๋ ์์ ์ฌ๋ฌ assert๋ฌธ์ ์ฌ์ฉํ๋ ๊ฒ์ ์ข์ง ์๋ค๊ณ ํด์! ํด๋น ๋ฉ์๋์์@ParameterizedTest ์ @MethodSource๋ฅผ ์ฌ์ฉํด๋ณด๋ฉด ์ด๋จ๊น์? |
@@ -0,0 +1,20 @@
+package christmas.domain.logic;
+
+import christmas.domain.model.DecemberEvent;
+
+public class ChristmasEventCalculator {
+ public static int calculateChristmasDiscount(int date) {
+ int startDay = DecemberEvent.getEventStartDate();
+ int discountPricePerDay = DecemberEvent.getDayDis... | Java | ์ ํธ๋ฆฌํฐ ํด๋์ค๋ก ๋ณด์ด๋๋ฐ ์์ฑ์๋ฅผ private๋ก ๋ง๋๋๊ฒ ์ข์๋ณด์ฌ์! ๐ |
@@ -0,0 +1,71 @@
+package christmas.domain.model;
+
+import christmas.domain.type.Menu;
+
+import java.util.*;
+
+public class DecemberEvent {
+ public static final int CHRISTMAS_DAY = 25;
+ private static final int EVENT_START_DATE = 1;
+ private static final int DAY_DISCOUNT_PRICE = 100;
+ private static ... | Java | ์์๋ฅผ ๊ด๋ฆฌํ๋ ํด๋์ค๋ฅผ ๋ค๋ฅธ ํจํค์ง๋ก ๊ตฌ๋ถํ๋ ๊ฑด ์ด๋จ๊น์? |
@@ -0,0 +1,103 @@
+package christmas.util;
+
+import christmas.domain.type.Menu;
+
+import java.util.*;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+public class OrderValidator {
+ private static final String LINE_SEPARATOR = System.lineSeparator();
+
+ private static final int MIN_AMO... | Java | getter๋ฅผ ์ฌ์ฉํ๋ ๋์ menu๊ฐ์ฒด๊ฐ ์ง์ ์นดํ
๊ณ ๋ฆฌ๋ฅผ ๋น๊ตํ๊ฒ ํด๋ณด๋๊ฑด ์ด๋จ๊น์? |
@@ -0,0 +1,61 @@
+package christmas.view;
+
+import camp.nextstep.edu.missionutils.Console;
+import christmas.domain.type.Menu;
+import christmas.util.DateValidator;
+import christmas.util.OrderValidator;
+import christmas.util.ValidationException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Inp... | Java | ๋ฐ๋ณต๋์ง๋ง ๋ฏธ์ธํ๊ฒ ๋ค๋ฅธ ์ฝ๋๋ค์! ์ด๋ป๊ฒ ๋ฐ๋ณต์ ์ค์ผ์ง ๊ณ ๋ฏผํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์์! ๐ |
@@ -0,0 +1,103 @@
+package christmas.util;
+
+import christmas.domain.type.Menu;
+
+import java.util.*;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+public class OrderValidator {
+ private static final String LINE_SEPARATOR = System.lineSeparator();
+
+ private static final int MIN_AMO... | Java | throw new ValidationException(INVALID_ORDER_MESSAGE + LINE_SEPARATOR + ******);
์ด๋ถ๋ถ์ด ๋ฐ๋ณต๋๋ค์! ์ ๋ ๋ฉ์๋๋ ์์๋ก ๋ฐ๋ณต์ ์ค์ผ ์ ์๋ค๊ณ ์๊ฐํ๋๋ฐ ์ด๋ค๊ฐ์? ๐ |
@@ -0,0 +1,28 @@
+package christmas.util;
+
+public class DateValidator {
+ private static final String INVALID_DATE_MESSAGE = "์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.";
+
+ public static void validateInput(String input) {
+ validateNumeric(input);
+ int date = Integer.parseInt(input);
+ validateDate(date... | Java | ์ ๋ง๋ค์ ์ ๊ฐ ์ถ๊ตฌํ๋ ๋ฐฉํฅ์ด `12์ ์ด๋ฒคํธ` ํด๋์ค๋ง ๋งค๋ฌ ํด๋นํ๋ ๋ฌ์ ๊ฐ์ ๋ผ์ฐ๋ ๊ฑฐ์๊ฑฐ๋ ์ `๋ช์.LAST_DATE` ์ด๋ฐ์์ผ๋ก ๋ฐ๊ฟ์ผ ๊ฒ ์ต๋๋ค. |
@@ -0,0 +1,76 @@
+package christmas.domain.logic;
+
+import christmas.domain.type.Badge;
+import christmas.domain.type.Menu;
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+public class EventCalculatorTest {
+
+ @Test
+ void isEligibleForEvent()... | Java | ์ค... ์์ง ํ
์คํธ์ฝ๋๊ฐ ์ต์์น์์๋๋ฐ ํ์ฉํด ๋ณด๊ฒ ์ต๋๋ค. |
@@ -0,0 +1,20 @@
+package christmas.domain.logic;
+
+import christmas.domain.model.DecemberEvent;
+
+public class ChristmasEventCalculator {
+ public static int calculateChristmasDiscount(int date) {
+ int startDay = DecemberEvent.getEventStartDate();
+ int discountPricePerDay = DecemberEvent.getDayDis... | Java | ์ํ ๊ตณ์ด ๊ฐ์ฒด๊ฐ ์์ฑ๋ ํ์๊ฐ ์๊ตฐ์ |
@@ -0,0 +1,71 @@
+package christmas.domain.model;
+
+import christmas.domain.type.Menu;
+
+import java.util.*;
+
+public class DecemberEvent {
+ public static final int CHRISTMAS_DAY = 25;
+ private static final int EVENT_START_DATE = 1;
+ private static final int DAY_DISCOUNT_PRICE = 100;
+ private static ... | Java | 12์ ์ด๋ฒคํธ์๋ ํ ์ธ ๊ธ์ก์ด๋ ๊ธฐ๊ฐ๋ฑ์ด ์์ด์ ๋น์ฆ๋์ค ๋ก์ง๊ณผ ๋ฐ์ ํ๋ค๊ณ ์๊ฐํด์ ์ ๊ธฐ์ ์์นํ๊ธด ํ์ต๋๋ค. |
@@ -0,0 +1,103 @@
+package christmas.util;
+
+import christmas.domain.type.Menu;
+
+import java.util.*;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+public class OrderValidator {
+ private static final String LINE_SEPARATOR = System.lineSeparator();
+
+ private static final int MIN_AMO... | Java | ํด๋น ๊ท์น์ ๋ํ ์ฑ
์์ ๋ฉ๋ด๋ณด๋ค๋ ์ฃผ๋ฌธ๊ฒ์ฆ์ ์๋ค๊ณ ์๊ฐํด์ ์ ๋ ๊ฒ ๊ตฌํํ๊ธด ํ๋๋ฐ ๋ฉ๋ด๊ฐ ์ค์ค๋ก ํ๋จ ํ ์ ์๋๊ฒ์ ์ข๋ ๊ตฌ๋ถํด๋์ผ๋ฉด ๋ ์ข์์ง๊ฒ ๋ค์! |
@@ -0,0 +1,41 @@
+package christmas.domain.model;
+
+import christmas.domain.type.Menu;
+
+import java.util.Map;
+
+public class OrderInfo {
+ private final int date;
+ private final Map<Menu, Integer> order;
+ private final int totalOrderPrice;
+
+ public OrderInfo(int date, Map<Menu, Integer> order) {
+ ... | Java | calculateTotalOrderPrice๋ก ํญ์ ๊ฐ์ ๊ตฌํ ์ ์์ผ๋ totalOrderPrice๋ฅผ ๋ฉค๋ฒ๋ณ์๋ก ๊ฐ๋ ๊ฒ ๋ณด๋ค ์ธ๋ถ์์ ๋ฉ์๋๋ฅผ ํธ์ถํ๋ ๋ฐฉ์์ ์ด๋ ์ ๊ฐ์? |
@@ -0,0 +1,58 @@
+package christmas.domain.type;
+
+public enum Menu {
+ //์ํผํ์ด์
+ MUSHROOM_SOUP("์์ก์ด์ํ", 6_000, Category.APPETIZER),
+ TAPAS("ํํ์ค", 5_500, Category.APPETIZER),
+ CAESAR_SALAD("์์ ์๋ฌ๋", 8_000, Category.APPETIZER),
+
+ //๋ฉ์ธ
+ T_BONE_STEAK("ํฐ๋ณธ์คํ
์ดํฌ", 55_000, Category.MAIN),
+ BBQ_RIBS("... | Java | ์๋ฐ ์คํธ๋ฆผ api ๋ฅผ ์ฌ์ฉํ์๋ฉด ์ธ๋ดํธ๋ฅผ ์ค์ด๊ณ ๋ช
ํ์ฑ์ ๋์ด์ค ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,58 @@
+package christmas.domain.type;
+
+public enum Menu {
+ //์ํผํ์ด์
+ MUSHROOM_SOUP("์์ก์ด์ํ", 6_000, Category.APPETIZER),
+ TAPAS("ํํ์ค", 5_500, Category.APPETIZER),
+ CAESAR_SALAD("์์ ์๋ฌ๋", 8_000, Category.APPETIZER),
+
+ //๋ฉ์ธ
+ T_BONE_STEAK("ํฐ๋ณธ์คํ
์ดํฌ", 55_000, Category.MAIN),
+ BBQ_RIBS("... | Java | InputView์์๋ ๋น์ทํ ์ฝ๋๋ก ๋ฉ๋ด ์ด๋ฆ์ ๊ฒ์ฆํ์๋๋ฐ null ์ ๋ฐํํ๋ ๋์ ์ฌ๊ธฐ์ ๋ฐ๋ก ์์ธ๋ฅผ ๋์ง์๋ ๊ฑด ์ด๋ ์ ๊ฐ์? |
@@ -0,0 +1,70 @@
+package christmas.domain.logic;
+
+import christmas.domain.model.DecemberEvent;
+import christmas.domain.type.Badge;
+import christmas.domain.type.Menu;
+
+import java.util.Collections;
+import java.util.Map;
+
+public class EventCalculator {
+ public static boolean isEligibleForEvent(int totalPric... | Java | ์ด ๋ฉ์๋์์ date๋ ์ฌ์ฉํ์ง ์๋๋ฐ ํ๋ผ๋ฏธํฐ๋ก ๋ฐ์ผ์๋ ์ด์ ๊ฐ ์์ผ์ค๊น์? |
@@ -0,0 +1,70 @@
+package christmas.domain.logic;
+
+import christmas.domain.model.DecemberEvent;
+import christmas.domain.type.Badge;
+import christmas.domain.type.Menu;
+
+import java.util.Collections;
+import java.util.Map;
+
+public class EventCalculator {
+ public static boolean isEligibleForEvent(int totalPric... | Java | Map<Menu, Integer> order ๋ก ์นดํ
์ฝ๋ฆฌ๋ณ ๋ฉ๋ด ๊ฐ์๋ฅผ ์
์ ์์ผ๋ ์ด๋ฅผ OrderInfo ๋ชจ๋ธ์ ์ญํ ๋ก ๋๊ธฐ์๋ ๊ฑด ์ด๋ ์ค๊น์? |
@@ -0,0 +1,61 @@
+package christmas.domain.model;
+
+import christmas.domain.type.Badge;
+import christmas.domain.type.Benefit;
+
+import java.util.Map;
+
+public class EventResult {
+ private final OrderInfo orderInfo;
+ private final Map<Benefit, Integer> benefitHistory;
+ private final int totalBenefitsPric... | Java | EventResult๋ dto๋ก ์ฌ์ฉํ์ ๊ฑธ๊น์? |
@@ -0,0 +1,103 @@
+package christmas.util;
+
+import christmas.domain.type.Menu;
+
+import java.util.*;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+public class OrderValidator {
+ private static final String LINE_SEPARATOR = System.lineSeparator();
+
+ private static final int MIN_AMO... | Java | More ๋ณด๋ค ๋ฉ์๋ ์๋๋ฅผ ๋ํ๋ด๋ ๋ฉ์๋๋ช
์ ์ฌ์ฉํ์๋ฉด ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,41 @@
+package christmas.domain.model;
+
+import christmas.domain.type.Menu;
+
+import java.util.Map;
+
+public class OrderInfo {
+ private final int date;
+ private final Map<Menu, Integer> order;
+ private final int totalOrderPrice;
+
+ public OrderInfo(int date, Map<Menu, Integer> order) {
+ ... | Java | ์์ ์ด ๊ฐ์ง ๊ฐ์ผ๋ก ํ๋ฒ ์ ํด์ง๊ณ ๋ณํ์ง ์๋ ๊ฐ์ด์ด์ ์ด๋ ๊ฒ ๊ตฌํํ์ต๋๋ค!
orderInfo์ ๊ฐ์ ๋ค๋ฅธ ๊ณณ์์ ํ์ฉ๋ฉ๋๋ค |
@@ -0,0 +1,58 @@
+package christmas.domain.type;
+
+public enum Menu {
+ //์ํผํ์ด์
+ MUSHROOM_SOUP("์์ก์ด์ํ", 6_000, Category.APPETIZER),
+ TAPAS("ํํ์ค", 5_500, Category.APPETIZER),
+ CAESAR_SALAD("์์ ์๋ฌ๋", 8_000, Category.APPETIZER),
+
+ //๋ฉ์ธ
+ T_BONE_STEAK("ํฐ๋ณธ์คํ
์ดํฌ", 55_000, Category.MAIN),
+ BBQ_RIBS("... | Java | ๋ค์ฌ๋ ์ฝ๋์์ ํ์ ๋ฐฐ์ ์ต๋๋ค! |
@@ -0,0 +1,58 @@
+package christmas.domain.type;
+
+public enum Menu {
+ //์ํผํ์ด์
+ MUSHROOM_SOUP("์์ก์ด์ํ", 6_000, Category.APPETIZER),
+ TAPAS("ํํ์ค", 5_500, Category.APPETIZER),
+ CAESAR_SALAD("์์ ์๋ฌ๋", 8_000, Category.APPETIZER),
+
+ //๋ฉ์ธ
+ T_BONE_STEAK("ํฐ๋ณธ์คํ
์ดํฌ", 55_000, Category.MAIN),
+ BBQ_RIBS("... | Java | ์ฑ
์์ ๋ถ๋ฆฌํ๋ ค๊ณ ๊ทธ๋ ๊ฒ ์์ฑํ์ต๋๋ค.
๋ฐ๋ก ๋ฉ๋ด์์ ์์ธ๋ฅผ ๋์ง๋ฉด ์ถ์ ํ๊ธฐ ์ฌ์ธ์ ์๊ฒ ๋ค์ |
@@ -0,0 +1,41 @@
+package christmas.domain.model;
+
+import christmas.domain.type.Menu;
+
+import java.util.Map;
+
+public class OrderInfo {
+ private final int date;
+ private final Map<Menu, Integer> order;
+ private final int totalOrderPrice;
+
+ public OrderInfo(int date, Map<Menu, Integer> order) {
+ ... | Java | date์ ๋ํ validation์ InputView์์ ์งํํ์
จ๊ตฐ์!
์ ๋ ์ด ๋ถ๋ถ์ ๋ํด์ ์ด๋ค ๊ฒ์ด ๋ ํจ์จ์ ์ผ๊น ๊ณ ๋ฏผ์ ๋ง์ด ํด๋ดค๋๋ฐ @T3rryAhn ๋์ ์๊ฐ์ ์ด๋ค ์ง ์ฌ์ญ๊ณ ์ถ์ต๋๋ค.
์ ๋ ์ฒ์์๋ ์
๋ ฅ๊ฐ์ ๋ํ validation์ InputView์์ ์ฒ๋ฆฌํ๋ ๊ฒ์ด ์ข์์ง domain์์ ์ฒ๋ฆฌํ๋ ๊ฒ์ด ์ข์ ์ง ๊ณ ๋ฏผ์ ๋ง์ด ํ์๋๋ฐ์. ํ๋ก๊ทธ๋จ์ด ๋ณต์กํด์ง ์๋ก InputView๊ฐ ๊ฒ์ฆํด์ผํ validation์ ์ข
๋ฅ๊ฐ ๋ง์์ง์ผ๋ก ์ ๋ validation์ domain์ผ๋ก ์ฑ
์์ ๋๊ธฐ๋ ๊ฒ์ด ๋ ์ข๋ค๊ณ ํ๋จํ์ต๋๋ค.
์๋ฅผ ๋ค์ด ์ ๋ In... |
@@ -0,0 +1,41 @@
+package christmas.domain.model;
+
+import christmas.domain.type.Menu;
+
+import java.util.Map;
+
+public class OrderInfo {
+ private final int date;
+ private final Map<Menu, Integer> order;
+ private final int totalOrderPrice;
+
+ public OrderInfo(int date, Map<Menu, Integer> order) {
+ ... | Java | Map<Menu, Integer>์ ๊ฒฝ์ฐ ์ปฌ๋ ์
์ ํด๋นํฉ๋๋ค.
์ด ๊ฒฝ์ฐ ์ผ๊ธ ์ปฌ๋ ์
์ ์ฌ์ฉํด์ ๊ด๋ฆฌํ๋ ๊ฑด ์ด๋จ๊น์?
์ฐธ๊ณ : https://tecoble.techcourse.co.kr/post/2020-05-08-First-Class-Collection/ |
@@ -0,0 +1,41 @@
+package christmas.domain.model;
+
+import christmas.domain.type.Menu;
+
+import java.util.Map;
+
+public class OrderInfo {
+ private final int date;
+ private final Map<Menu, Integer> order;
+ private final int totalOrderPrice;
+
+ public OrderInfo(int date, Map<Menu, Integer> order) {
+ ... | Java | 3์ฃผ์ฐจ ๊ณตํต ํผ๋๋ฐฑ์์ '**๊ฐ์ฒด๋ ๊ฐ์ฒด๋ต๊ฒ **'๋ผ๋ ๊ฒ์ด ์์์ต๋๋ค.
์ด ๊ฒฝ์ฐ `private final Map<Menu, Integer> order;`์ผ๋ก ์ ์ธํ order์ ๋ฐํํ๋๋ฐ์.
Map<Menu, Integer>์ ์ปฌ๋ ์
์ค์ ํ๋์
๋๋ค.
๋ฐ๋ผ์ final ํค์๋๋ฅผ ์ฌ์ฉํ๋ค๊ณ ํด๋ ๊ฐ์ ๋ณ๊ฒฝ์ด ๋ฐ์ํ ์ ์์ต๋๋ค ใ
ใ
กใ
.
๋ฐ๋ผ์ ์ปฌ๋ ์
๋ณ์๋ ์ต๋ํ getter ์ฌ์ฉ์ ์ง์ํ๊ณ ๊ฐ์ฒด์ ๋ฉ์์ง๋ฅผ ๋์ง๋ ๋ฐฉ์์ผ๋ก ์ฒ๋ฆฌํ๋ฉด ์ข์๋ฐ์.
์์ comment์ ์ฐ๊ดํ์ฌ '์ผ๊ธ์ปฌ๋ ์
' ๊ฐ๋
์ด ๋ง์ด ๋์ ๋์ค ๊ฒ ๊ฐ์ต๋๋ค!
์ฐธ๊ณ : https:... |
@@ -0,0 +1,112 @@
+package christmas.view;
+
+import christmas.domain.model.DecemberEvent;
+import christmas.domain.model.EventResult;
+import christmas.domain.type.Badge;
+import christmas.domain.type.Benefit;
+import christmas.domain.type.Menu;
+import christmas.util.MapToStringConverter;
+
+import java.util.Map;
+
+... | Java | OutputView์์ ์ฌ์ฉ๋๋ ์์๊ฐ ๊ฒฝ์ฐ, enum์ผ๋ก ๋ฌถ์ด์ ๊ด๋ฆฌํ๋ฉด ์ฝ๋๊ฐ ํจ์ฌ ๊น๋ํ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,173 @@
+์์ฑ์: ์ํ๋ฆฌ
+
+# ๐
ํฌ๋ฆฌ์ค๋ง์ค ํ๋ก๋ชจ์
+
+**์ด๋ฒคํธ ๋ชฉํ**
+````
+1. ์ค๋ณต๋ ํ ์ธ๊ณผ ์ฆ์ ์ ํ์ฉํด์, ๊ณ ๊ฐ๋ค์ด ํํ์ ๋ง์ด ๋ฐ๋๋ค๋ ๊ฒ์ ์ฒด๊ฐํ ์ ์๊ฒ ํ๋ ๊ฒ
+2. ์ฌํด 12์์ ์ง๋ 5๋
์ค ์ต๊ณ ์ ํ๋งค ๊ธ์ก์ ๋ฌ์ฑ
+3. 12์ ์ด๋ฒคํธ ์ฐธ์ฌ ๊ณ ๊ฐ์ 5%๊ฐ ๋ด๋
1์ ์ํด ์ด๋ฒคํธ์ ์ฌ์ฐธ์ฌํ๋ ๊ฒ
+````
+
+---------------
+## โ ๊ธฐ๋ฅ ๋ชฉ๋ก
+
+### ์ฌ์ฉ์ ์ธํฐํ์ด์ค
+ - ์ฌ์ฉ์์๊ฒ ์
๋ ฅ์ ์์ฒญํ๋ ์๋ด ๋ฉ์์ง ์ถ๋ ฅ
+ - ์ฌ์ฉ์ ์
๋ ฅ ์๋ฌ ๋ฐ์ ์, '[ERROR]'๋ก ์... | Unknown | README ๊น๋ํด์ ์ ๋ฆฌ๊ฐ ์ ๋ ๊ฒ ๊ฐ์ต๋๋ค :) |
@@ -0,0 +1,116 @@
+package christmas.domain.logic;
+
+import christmas.domain.model.DecemberEvent;
+import christmas.domain.model.OrderInfo;
+import christmas.domain.model.EventResult;
+import christmas.domain.type.Badge;
+import christmas.domain.type.Benefit;
+import christmas.domain.type.Menu;
+
+import java.util.Has... | Java | EventService๋ผ๋ ๊ฐ์ฒด์ ์กด์ฌ ์ด์ ๊ฐ ์ ์๋ฟ์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ์๋น์ค ๊ฐ์ฒด์ธ์ง, ์ ํธ์ฉ ๊ฐ์ฒด์ธ์ง, ํน์ ๋๋ฉ์ธ ๊ฐ์ฒด์ธ์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ์๋น์ค ๊ฐ์ฒด๋ผ๋ฉด logic์ด๋ผ๋ ํจํค์ง๋ช
์ด ๋ชจํธํ๋ค๊ณ ์๊ฐํ๊ณ , service ํจํค์ง๋ฅผ ๋ง๋ค์ด ๊ทธ ํ์ ์์ด์ผ ํ ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,82 @@
+package christmas.controller;
+
+import static christmas.domain.event.EventConstants.*;
+
+import christmas.domain.restaurant.Orders;
+import christmas.domain.restaurant.VisitDate;
+import christmas.service.RestaurantCalculator;
+import christmas.view.inputview.InputValueType;
+import christmas.view.i... | Java | ๊ฐ์ธ์ ์ธ ์๊ฐ์ผ๋ก, ์ปจํธ๋กค๋ฌ๊ฐ ๋ค๋ฅธ ์ปจํธ๋กค๋ฌ๋ฅผ ์ธ์คํด์ค ๋ณ์๋ก ๊ฐ์ง๊ณ ํธ์ถํ๋ ๊ฒ์ด ๋ง๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
๋ง์ฝ ๊ณตํต๋ ๋ถ๋ถ์ด ์์ด์๋ผ๋ฉด, ์๋น์ค๋ฅผ ๋ฐ๋ก ๋๊ฑฐ๋ ์ปจํธ๋กค๋ฌ๋ฅผ ํ๋๋ก ํฉ์น๋๊ฑธ ์ถ์ฒ๋๋ฆฝ๋๋ค! |
@@ -0,0 +1,78 @@
+package christmas.domain.restaurant;
+
+import christmas.domain.food.Dessert;
+import christmas.domain.food.Food;
+import christmas.domain.food.MainFood;
+import christmas.util.parser.Parser;
+import christmas.util.validator.OrderValidator;
+import java.util.Collections;
+import java.util.HashMap;
+im... | Java | Map ์๋ฃ๊ตฌ์กฐ๋ ์ฐ๋ค๋ณด๋ฉด ์๊ทผ ์์ด ๋ง์ด ๊ฐ๊ฒ๋๋ ์๋ฃ๊ตฌ์กฐ๋ผ๋ ์๊ฐ์ด ๋ค๋๋ผ๊ตฌ์.
๋ฌผ๋ก ์๋ฃ๊ตฌ์กฐ๋ง๋ค ์ฅ์ ๊ณผ ๋จ์ ์ด ์์ง๋ง
๊ฐ์ธ์ ์ผ๋ก ์ฌ๊ธฐ์๋ Map๋ณด๋ค๋ ๋ฉ๋ด์ ๊ฐ์๋ฅผ ๊ฐ์ง ๋ณ๋์ Order ๊ฐ์ฒด๋ฅผ ๋๋ ๊ฒ์ด ์ข์๋ณด์
๋๋ค! |
@@ -0,0 +1,82 @@
+package christmas.controller;
+
+import static christmas.domain.event.EventConstants.*;
+
+import christmas.domain.restaurant.Orders;
+import christmas.domain.restaurant.VisitDate;
+import christmas.service.RestaurantCalculator;
+import christmas.view.inputview.InputValueType;
+import christmas.view.i... | Java | ํด๋น ๋ถ๋ถ์ ์ด๋ฒคํธ ๋๋ฉ์ธ ๊ด๋ จ ํด๋์ค์ ์์นํ๋ ๊ฒ์ด ์ข์๋ณด์
๋๋ค.
์ด๋ฒคํธ๋ฅผ ์ ์ฉํ ์ ์๋์ง ์๋์ง์ ๋ํด์๋ ๋น์ฆ๋์ค ๋ก์ง์ ํด๋น๋๋ค๊ณ ์๊ฐํด์! |
@@ -0,0 +1,82 @@
+package christmas.controller;
+
+import static christmas.domain.event.EventConstants.*;
+
+import christmas.domain.restaurant.Orders;
+import christmas.domain.restaurant.VisitDate;
+import christmas.service.RestaurantCalculator;
+import christmas.view.inputview.InputValueType;
+import christmas.view.i... | Java | ๋ง์ฐฌ๊ฐ์ง์ ์ด์ ๋ก, view์์๋ ๋๋ฉ์ธ ๋ชจ๋ธ ์์ฒด๊ฐ ์๋ ๋๋ฉ์ธ ๋ชจ๋ธ์ ๋ฐ์ดํฐ๋ง ์ ๋ฌํ๋ ๊ฒ์ด ์ข๋ค๊ณ ์๊ฐํฉ๋๋ค |
@@ -0,0 +1,82 @@
+package christmas.controller;
+
+import static christmas.domain.event.EventConstants.*;
+
+import christmas.domain.restaurant.Orders;
+import christmas.domain.restaurant.VisitDate;
+import christmas.service.RestaurantCalculator;
+import christmas.view.inputview.InputValueType;
+import christmas.view.i... | Java | ์ด ๋ถ๋ถ์ ๊ตฌ์กฐ ๊ฐ์ ์ด ํ์ํ๊ฒ ๋ค์. ๋ง์ํด์ฃผ์ ๋๋ก ์ปจํธ๋กค๋ฌ ๋ด๋ถ์ ์ปจํธ๋กค๋ฌ๋ฅผ ๋ ํ์๋ ์์๋ค๊ณ ์๊ฐํฉ๋๋ค. EventPlanerController๋ Service์ ๋๋ ๊ฒ ๋ง์๊ฒ ๋ค์.
๋๋ถ์ ์ด๋ ดํํ๊ฒ ์์๋ ์๋น์ค์ ์ปจํธ๋กค๋ฌ์ ์ญํ ์ ๋ํด ๋ค์ ํ ๋ฒ ์๊ฐํด๋ณผ ์ ์๋ ๊ธฐํ๊ฐ ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ข์ ํผ๋๋ฐฑ ๊ฐ์ฌํฉ๋๋ค! |
@@ -0,0 +1,82 @@
+package christmas.controller;
+
+import static christmas.domain.event.EventConstants.*;
+
+import christmas.domain.restaurant.Orders;
+import christmas.domain.restaurant.VisitDate;
+import christmas.service.RestaurantCalculator;
+import christmas.view.inputview.InputValueType;
+import christmas.view.i... | Java | ์ ๊ฐ ํด๋น ๋ถ๋ถ์ ๊ธฐ๋ฅ ๊ตฌํ์ ๊น๋จน๊ณ ์๋ค๊ฐ ๋ง์ง๋ง์ ํ๊ฒ ๋์๋๋ฐ, ์ด๋ฌํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ค์.
๊ธฐ๋ณธ MVC ํจํด์ ์ปจํธ๋กค๋ฌ ์ญํ ์ ์๊ฐํด๋ณด๋ฉด ์ด๋ฒคํธ ๋๋ฉ์ธ์ด๋ ์๋น์ค์์ ํด๋น ๋ก์ง์ ์ฒ๋ฆฌํ๋ ๊ฒ์ด ์ข์๋ณด์
๋๋ค. ๊ฐ์ฌํฉ๋๋ค! |
@@ -0,0 +1,106 @@
+package christmas;
+
+import christmas.domain.badge.BadgeService;
+import christmas.domain.badge.model.Badge;
+import christmas.domain.benefit.BenefitService;
+import christmas.domain.benefit.model.Benefits;
+import christmas.domain.bills.Bills;
+import christmas.domain.date.DateService;
+import chri... | Java | ์ ๋ ํญ์ print๋ถ๋ถ์ด ์ง์ ๋ถํด์ ธ์ ์ด๋ป๊ฒ ์ฒ๋ฆฌํ ์ง ๊ณ ๋ฏผ์ ๋ง์ดํ๋๋ฐ, ์ค๋ ๋ณด๊ณ ๊ณต๋ถํด์ผ๊ฒ ์ต๋๋ค ใ
ใ
๐ |
@@ -0,0 +1,41 @@
+package christmas.domain.badge.model;
+
+import java.util.Arrays;
+
+public enum Badge {
+ NONE("์์", 0, 5_000),
+ STAR("๋ณ", 5_000, 10_000),
+ TREE("ํธ๋ฆฌ", 10_000, 20_000),
+ SANTA("์ฐํ", 20_000, Integer.MAX_VALUE);
+
+ private static final Badge[] badges = Badge.values();
+ private fin... | Java | ์ ์ ์ ์ฌํ์ง๋ง ๊ฐ์ ๋ฒ์๋ฅผ ์ ํด์ฃผ์๊ณ ํ์ํ์
จ๊ตฐ์ ! |
@@ -0,0 +1,15 @@
+package christmas.domain.benefit.constance;
+
+public interface BenefitConst {
+ String GIFT_DESCRIPTION = "์ฆ์ ์ด๋ฒคํธ";
+
+ int D_DAY_INITIAL_PRICE = 1_000;
+ int D_DAY_INCREASE_PRICE = 100;
+ int WEEKDAY_DISCOUNT_PRICE = 2_023;
+ int WEEKEND_DISCOUNT_PRICE = 2_023;
+ int SPECIAL_DISCOU... | Java | ์ ๋ ๋ง์ ๊ณ ๋ฏผ์ ํ์๋ ๋ถ๋ถ์ธ๋ฐ, enum์ผ๋ก ๊ด๋ฆฌํ์ง ์๊ณ ์ธํฐํ์ด์ค ์์์ ์์๋ก ๊ด๋ฆฌํ์๋ ์ด์ ๊ฐ ์์๊น์? |
@@ -0,0 +1,32 @@
+package christmas.domain.benefit;
+
+import christmas.domain.benefit.constance.BenefitConst;
+import christmas.domain.benefit.model.Benefit;
+import christmas.domain.benefit.model.Benefits;
+import christmas.domain.benefit.model.discount.DiscountFactories;
+import christmas.domain.benefit.model.gift.G... | Java | ์ฝ๋๊ฐ ์ธ์์ ์ด๋ค์ :) |
@@ -0,0 +1,11 @@
+package christmas.domain.benefit.model;
+
+import christmas.domain.date.model.PromotionDay;
+import christmas.domain.menu.model.collection.OrderSheet;
+
+public interface BenefitFactory {
+
+ boolean canApply(PromotionDay promotionDay, OrderSheet orderSheet);
+
+ Benefit generate(PromotionDay pr... | Java | generate๋ผ๋ ๋ค์ด๋ฐ์ ์ฃผ๋ก ์ด๋ค ์๋ฏธ๋ฅผ ์ ๋ฌํ๋ ค๊ณ ํ์ค ๋ ์ฌ์ฉํ์๋์? |
@@ -0,0 +1,44 @@
+package christmas.domain.benefit.model.discount;
+
+import christmas.domain.benefit.model.Benefit;
+import java.util.Objects;
+
+public class Discount implements Benefit {
+ private final DiscountType type;
+ private final int price;
+
+ Discount(DiscountType type, int price) {
+ this.... | Java | price๋ ๊ฐ์์ผ ํ ๊น์? |
@@ -0,0 +1,59 @@
+package christmas.domain.date.model;
+
+import christmas.domain.date.constance.DateConst;
+import christmas.exception.PromotionException;
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.util.Set;
+
+public class PromotionDay {
+
+ private static final Set<DayOfWeek> weekend =... | Java | Start day๊ฐ ์๊ตฌ์ฌํญ์ ๋ฐ๋ผ ๋ณ๊ฒฝ๋ ์ ์๋ค๊ณ ์๊ฐํด์ 1์ ์์๋ก ๊ด๋ฆฌ ํด์คฌ์๋๋ฐ, ๋งค์ง ๋๋ฒ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ๊ณผ ์์๋ก ๊ด๋ฆฌํ๋ ๊ฒ์ค ์ด๋๊ฒ์ด ๋ ๊ด์ฐฎ์๊น์?? |
@@ -0,0 +1,41 @@
+package christmas.domain.badge.model;
+
+import java.util.Arrays;
+
+public enum Badge {
+ NONE("์์", 0, 5_000),
+ STAR("๋ณ", 5_000, 10_000),
+ TREE("ํธ๋ฆฌ", 10_000, 20_000),
+ SANTA("์ฐํ", 20_000, Integer.MAX_VALUE);
+
+ private static final Badge[] badges = Badge.values();
+ private fin... | Java | ์ด๊ฑฐํ ๊ฐ๋ค์ ์บ์ฑํด๋๋ ์ ๋ต์ด ์ ๋ง ์ข์ ๊ฒ ๊ฐ์ต๋๋ค :)
์ถ๊ฐ์ ์ผ๋ก `Badge[]`๋ก ๋ฐฐ์ง๋ค์ ์บ์ฑํด๋ ์ด์ ๋ ๊ถ๊ธํฉ๋๋ค!
์บ์ฑ์ ํ์ง๋ง ๋ฐฐ์ด์ด๊ธฐ ๋๋ฌธ์ ์ด์ฉ ์ ์์ด ์ํํ๋ ์์
์ด ํ์ํ๋ฐ, ์ด๋ค ์ ์ ์ผ๋ํด์ ์บ์ฑํ์ ๊ฑด์ง ๊ถ๊ธํด์!!
๋งค ๋ฒ `.values()`๋ฅผ ํธ์ถํ๋ ๊ฒ์ ๋นํจ์จ์ ์ด๋ผ ํ๋จํ์ ๊ฑธ๊น์?! |
@@ -0,0 +1,41 @@
+package christmas.domain.badge.model;
+
+import java.util.Arrays;
+
+public enum Badge {
+ NONE("์์", 0, 5_000),
+ STAR("๋ณ", 5_000, 10_000),
+ TREE("ํธ๋ฆฌ", 10_000, 20_000),
+ SANTA("์ฐํ", 20_000, Integer.MAX_VALUE);
+
+ private static final Badge[] badges = Badge.values();
+ private fin... | Java | ๋ฐฐ์ง์ ์ต์๊ฐ๊ณผ ์ต๋๊ฐ์ ๋ฉค๋ฒ ๋ณ์๋ก ์ค์ ํด์ฃผ๊ณ , Predicate์ผ๋ก ์ฒ๋ฆฌํ๋ฉด ํ๋์ ๋ฉ์๋๋ก ์ฒ๋ฆฌํ ์ ์๋ค์..
์ ๋ง ์ข์ ์ฝ๋์ธ ๊ฒ ๊ฐ์์! ์ ๋ ์ต๋๊ฐ์ ์๊ฐ ๋ชปํด์ if ๋ถ๊ธฐ๋ฌธ์ด ์ฌ๋ฌ๊ฐ ๋ค์ด๊ฐ๋๋ฐ, ํ์๋ ์ฝ๋์ฒ๋ผ ๊ฐ์ ํ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค ๐ |
@@ -0,0 +1,41 @@
+package christmas.domain.badge.model;
+
+import java.util.Arrays;
+
+public enum Badge {
+ NONE("์์", 0, 5_000),
+ STAR("๋ณ", 5_000, 10_000),
+ TREE("ํธ๋ฆฌ", 10_000, 20_000),
+ SANTA("์ฐํ", 20_000, Integer.MAX_VALUE);
+
+ private static final Badge[] badges = Badge.values();
+ private fin... | Java | NONE์ผ๋ก ์์ ์ฒ๋ฆฌํ์ ๊ฒ๋ ์ข์ ์ ๊ทผ ๋ฐฉ๋ฒ์ด๋ผ ์๊ฐํฉ๋๋ค :)
`Optional`๋ ๊ณ ๋ คํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์์!
๊ทธ๋ ๊ฒ ๋๋ฉด from ๋ฉ์๋๊ฐ ์ด๋ฐ์์ผ๋ก ๋ฐ๋ ๊ฒ ๊ฐ์ต๋๋ค.
```java
public static Optional<Badge> from(int price) {
Optional<Badge> result = Arrays.stream(badges)
.filter(badge -> badge.match(price))
.findFirst();
if(result.isPresen... |
@@ -0,0 +1,32 @@
+package christmas.domain.benefit;
+
+import christmas.domain.benefit.constance.BenefitConst;
+import christmas.domain.benefit.model.Benefit;
+import christmas.domain.benefit.model.Benefits;
+import christmas.domain.benefit.model.discount.DiscountFactories;
+import christmas.domain.benefit.model.gift.G... | Java | if ์กฐ๊ฑด๋ฌธ์ ๊ฐ์ธ์ ์ผ๋ก ๋ฉ์๋ ๋ถ๋ฆฌํ๋ ๊ฒ๋ ๊ด์ฐฎ์ ๊ฒ ๊ฐ์ต๋๋ค!
๊ทธ ์ด์ ๋ 20, 21 line์์ ๋ฉ์๋ ํธ์ถ์ ํตํด ๋ก์ง์ ์ฒ๋ฆฌํ๊ณ ์๊ธฐ ๋๋ฌธ์, ๋์ผํ depth๋ก ํต์ผ์์ผ ์ฃผ์ ๋ค๋ฉด ์กฐ๊ธ ๋ ์ฝ๊ธฐ ์ข์ ์ฝ๋๊ฐ ๋ ์ ์์ ๊ฒ ๊ฐ์์ :) |
@@ -0,0 +1,19 @@
+package christmas.domain.benefit.model.discount;
+
+public enum DiscountType {
+ D_DAY("ํฌ๋ฆฌ์ค๋ง์ค ๋๋ฐ์ด ํ ์ธ"), //12์ 25์ผ์ ์ง๋์ง ์์ ๊ฒฝ์ฐ //๋ ์ง์ ๋ฐ๋ผ 100์์ฉ ์ฆ๊ฐ
+ WEEKDAY("ํ์ผ ํ ์ธ"), //ํ์ผ์ธ ๊ฒฝ์ฐ // ๋์ ํธ ๋ฉ๋ด * ๊ธ์ก
+ WEEKEND("์ฃผ๋ง ํ ์ธ"), //์ฃผ๋ง์ธ ๊ฒฝ์ฐ // ๋ฉ์ธ ๋ฉ๋ด * ๊ธ์ก
+ SPECIAL("ํน๋ณ ํ ์ธ") //์คํ์
๋ฐ์ด์ธ ๊ฒฝ์ฐ // ๋ฌด์กฐ๊ฑด 1000์
+ ;
+
+ p... | Java | ์ ๋ `ํ ์ธ ์ ํ(DiscountType)`, `ํ ์ธ ์ ํ์ ๋ํ ๋ ์ง`, `ํ ์ธ ์ ํ์ ๋ํ ํ ์ธ ๊ณ์ฐ ๋ก์ง`
์์ 3๊ฐ์ง๋ DiscountType Enum๊ณผ **์์ฃผ ๊ธด๋ฐํ๊ฒ ์ฐ๊ด๋์ด ์๋ ์์**๋ผ ์๊ฐ์ด ๋ค์์ต๋๋ค!
๊ทธ๋์ ์ด๋ฐ์์ผ๋ก DiscountType์ ๊ตฌํํ์ต๋๋ค.
```java
public enum DiscountType {
CHRISTMAS("ํฌ๋ฆฌ์ค๋ง์ค ๋๋ฐ์ด ํ ์ธ", EventDayCalculator.christmasDay(), orderDay -> {
final int basicDiscountAmount = 1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.