code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -0,0 +1,51 @@
+import useProducts from "../../hooks/useProducts";
+import ProductListHeader from "../ProductListHeader/ProductListHeader";
+import ProductItem from "./ProductItem/ProductItem";
+import * as PL from "./ProductList.style";
+import useInfiniteScroll from "../../hooks/useInfiniteScroll";
+import usePagin... | Unknown | ํ์ฌ ์๋ก์ด fetch๋ฅผ ํตํด ์๋ก์ด ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ง๊ณ ์ค๋ฉด ์คํฌ๋กค ์์น๊ฐ ๊ฐ์ ๋ก ์ฌ๋ผ๊ฐ๋ ๋ฒ๊ทธ๊ฐ ์์ต๋๋ค. ์ ๊ฐ ์๊ฐํ๊ธฐ์๋ ProductListStyle๊ฐ ์กฐ๊ฑด๋ถ๋ก ๋ ๋๋ง๋์ด ์ปดํฌ๋ํธ๊ฐ ๋งค๋ฒ ์๋กญ๊ฒ ๋ง๋ค์ด์ง๋๋ค. ๊ทธ๋์ ๋ฆฌ์กํธ๊ฐ ๋์ผํ ์ปดํฌ๋ํธ๋ก ์ธ์งํ์ง ๋ชปํด์ ๋ฐ์ํ ๋ฌธ์ ๊ฐ์ต๋๋ค. ๋ค์๊ณผ ๊ฐ์ ์ฝ๋๋ก ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค.
```tsx
return (
<>
<ProductListHeader
handleCategory={handleCategory}
handleSort={handleSort}
/... |
@@ -0,0 +1,49 @@
+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 | fetch์ ๊ณตํต๋ ๋ก์ง์ ๋๋ฒ์ด๋ ๊ฐ์ธ์ ๊น๋ํ๊ฒ ์ ๋ฆฌํด ์ค ๊ฒ์ด ๋ง์์ ๋๋ค์~!
์ ๋ฏธ์
์๋ ์ ์ฉ์์ผ๋ด์ผ๊ฒ ์ด์ ใ
ใ
ใ
๐ ๐๐๐ |
@@ -0,0 +1,118 @@
+import { RULE } from "../constants/rules";
+import {
+ CART_ITEMS_COUNTS_ENDPOINT,
+ CART_ITEMS_ENDPOINT,
+ PRODUCTS_ENDPOINT,
+} from "./endpoints";
+import { fetchWithAuth } from "./fetchWithAuth";
+
+interface QueryParams {
+ [key: string]:
+ | undefined
+ | string
+ | number
+ | b... | TypeScript | ์๋ง key๋ก ์ ๊ทผํด์ ๊ฐ์ ๊ฐ์ ธ์ค๊ธฐ ์ํด์ index signature๋ฅผ ์ฌ์ฉํ๋ ค๊ณ ํ์
จ๋ ๊ฑธ๊น์?!
ํ์ง๋ง ์ด๋ ๊ฒ ๋๋ฉด, ์์์น ๋ชปํ๊ฒ `page = "page1"` ๊ณผ ๊ฐ์ prop์ด๋
์๋ํ์ง ์์ key๊ฐ์ด ๋ค์ด์ฌ ๊ฒฝ์ฐ, queryParams interface์์ ๊ฑธ๋ฌ์ง์ง ์์ ๊ฒ ๊ฐ์์.
์ฌ์ ์์ผ์ค ๋ ํ๋ฒ ์๊ฐํด ๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์์ :) |
@@ -0,0 +1,34 @@
+import styled from "styled-components";
+
+export const ButtonStyle = styled.button`
+ cursor: pointer;
+ border: none;
+ outline: none;
+`;
+
+export const CartControlButtonStyle = styled(ButtonStyle)`
+ display: flex;
+ position: absolute;
+ right: 8px;
+ align-items: center;
+ border-radius... | TypeScript | ์ ๋ Button์ Prop์ ๋ฐ์์ ์์์ ๋ฐ๊ฟ์ฃผ๋ ์์ผ๋ก ์์ฑํ์ด์!
```suggestion
export const ButtonStyle = styled.button<ButtonProps>`
cursor: pointer;
border: none;
outline: none;
${({ color }) => {
if (color === "primary") {
return `
background-color: black;
color: white;
`;
}
... |
@@ -0,0 +1,39 @@
+import styled from "styled-components";
+
+export const HeaderStyle = styled.header`
+ display: flex;
+ background-color: #000000;
+ width: inherit;
+ height: 64px;
+ position: fixed;
+ z-index: 1;
+ padding: 16px 24px 16px;
+ box-sizing: border-box;
+`;
+
+export const LogoImg = styled.img`
+... | TypeScript | ํ๋ก์ ํธ์ ์ปดํฌ๋ํธ ๊ท๋ชจ๊ฐ ๋ณต์กํด์ง๋ฉด, zindex ๊ด๋ฆฌ๊ฐ ํ๋ค๋๋ผ๊ตฌ์
ํค๋๋ฅผ 1๋ก ํด๋จ๋๋ฐ, ํค๋๋ณด๋ค ๋ฎ์ ์ด๋ ํ component๊ฐ ์๊ธธ์๋ ์๊ณ ...!
๊ทธ๋์ ์ ๋ ์ถ์ฒ๋ฐ์ ๋ฐฉ๋ฒ์ด zIndex๋ค์ ์์๋ก ๊ด๋ฆฌํด์ ํ๊ณณ์์ ํธํ๊ฒ ๋ณผ ์ ์๋๋ก ํ๋๊ฑฐ์์ด์
์ ๋ ์์ฃผ ์ฌ์ฉํ์ง ์์ง๋ง, ๊ฟํ ๊ณต์ ํด๋ด
๋๋ค ใ
ใ
|
@@ -0,0 +1,57 @@
+import {
+ createContext,
+ useState,
+ ReactNode,
+ useEffect,
+ useCallback,
+} from "react";
+import { getCartItems } from "../api";
+import { useErrorContext } from "../hooks/useErrorContext";
+
+export interface CartItemsContextType {
+ cartItems: CartItem[];
+ refreshCartItems: () => void... | Unknown | ์ ๋ Quantity๋ง์ context๋ก ๊ด๋ฆฌํ๋๋ฐ, ์ ์ฒด List๋ฅผ context ๋ก ๊ด๋ฆฌํ์
จ๊ตฐ์!!
Provider๋ฅผ custom ํด์ฃผ๋ ๊ฒ๋ ๋งค์ฐ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค :)
์ข์ ์ ๋ณด ๋ฐฐ์ฐ๊ณ ๊ฐ๋๋ค!! |
@@ -0,0 +1,34 @@
+import styled from "styled-components";
+
+export const ButtonStyle = styled.button`
+ cursor: pointer;
+ border: none;
+ outline: none;
+`;
+
+export const CartControlButtonStyle = styled(ButtonStyle)`
+ display: flex;
+ position: absolute;
+ right: 8px;
+ align-items: center;
+ border-radius... | TypeScript | Button์ `hover` ์์ฑ๋ ์์ผ๋ฉด ์ด๋จ๊น ์ถ๋ค์! |
@@ -0,0 +1,37 @@
+import { forwardRef } from "react";
+import * as PI from "./ProductItem.style";
+import CartControlButton from "../../Button/CartControlButton";
+import useProductInCart from "../../../hooks/useProductInCart";
+
+interface ProductProps {
+ product: Product;
+}
+
+const ProductItem = forwardRef<HTMLDi... | Unknown | ํน์ try-catch ์์ catch๋๋ error๊ฐ `Error` ํ์
์ด ์๋ ๊ฒฝ์ฐ๋ ์๋์?!
๋จ์ํ ๊ถ๊ธํด์ ์ฌ์ญค๋ด
๋๋ค...!
catch๋๋ ๊ฒ์ Error๋ง catch๋๋์ค ์์์, ์ด ๋ก์ง์ด ํ์ํ๊ฐ ํ๋ ์๊ฐ์ด ๋ค์์ด์ ใ
ใ
|
@@ -0,0 +1,51 @@
+import useProducts from "../../hooks/useProducts";
+import ProductListHeader from "../ProductListHeader/ProductListHeader";
+import ProductItem from "./ProductItem/ProductItem";
+import * as PL from "./ProductList.style";
+import useInfiniteScroll from "../../hooks/useInfiniteScroll";
+import usePagin... | Unknown | ์ค... ํด๊ฒฐ๋ฒ ์ ์๊น์ง ๋๋จํ๋ค์ ๐ ๐๐๐๐๐๐ |
@@ -0,0 +1,49 @@
+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 | `requestBuilder` ๋ผ๋ ์ด๋ฆ์ผ๋ก ์์ฒญ์ ๋ง๋๋ ์ฑ
์์ ๊ฐ์ง ํจ์๋ฅผ ๋ณ๋๋ก ๋ถ๋ฆฌํด์ฃผ์ ๋ถ๋ถ์ด ์ธ์๊น๋ค์!๐๐ |
@@ -0,0 +1,57 @@
+import {
+ createContext,
+ useState,
+ ReactNode,
+ useEffect,
+ useCallback,
+} from "react";
+import { getCartItems } from "../api";
+import { useErrorContext } from "../hooks/useErrorContext";
+
+export interface CartItemsContextType {
+ cartItems: CartItem[];
+ refreshCartItems: () => void... | Unknown | `useCallback`๊ณผ`toggle`์ด๋ผ๋ ์ํ๋ฅผ ํตํด `fetchCartItems`์ ์ฌ์คํ์ํจ๋ค๋ ๋ฐ์์ด ๋ชน์ ์๋กญ๊ฒ ๋๊ปด์ง๋ค์! ํ ๋ฒ๋ ์๊ฐํด๋ณด์ง ๋ชปํ๋ ๋ฐฉ์์ธ๋ฐ... ์ํ๋ ์ต์ํ๋์ด์ผ ํ๋ค๊ณ ์๊ฐํ๋ ํธ์ด์ง๋ง, ํน์ ํธ๋ฆฌ๊ฑฐ๋ฅผ ์ํด ์ํ๋ฅผ ํ์ฉํ๋ ๊ฒ์ด ์ข์์ง ์ ๋ ํ ๋ฒ ๊ณ ๋ฏผํด๋ณผ ์ ์์๋ ๊ฒ ๊ฐ์์!
ํํธ์ผ๋ก๋ ์ํ๋ฅผ ๋ง๋ค์ง์๊ณ , `fetchCartItems`๋ก์ง์ `useEffect` ๋ฐ์ผ๋ก ๋บ ๋ค refreshCartItems ์ ์ ์์ฑํด์ฃผ๋ฉด ์ํ๊ฐ ํ์ํ์ง ์์ ๊ฒ ๊ฐ๋ค๋ ์๊ฐ์ด ๋ค๊ธฐ๋ ํฉ๋๋ค! (์ด ๋ถ๋ถ์ ๊ฐ๋ฐ์์ ์ทจํฅ์ด๋ ์ ํธ์ ๊ฐ๊น์ธ... |
@@ -0,0 +1,15 @@
+import { useContext } from "react";
+import {
+ CartItemsContext,
+ CartItemsContextType,
+} from "../context/CartItemsContext";
+
+export const useCartItemsContext = (): CartItemsContextType => {
+ const context = useContext(CartItemsContext);
+ if (!context) {
+ throw new Error(
+ "useCa... | TypeScript | ํ์ฌ `useErrorContext`์ `useCartItemsContext`๋ context๊ฐ `undefined`์ธ ๊ฒฝ์ฐ ์๋ฌ๋ฅผ ๋์ ธ ํ์
์ ์ขํ๊ธฐ ์ํ ์ปค์คํ
ํ
์ธ ๊ฒ ๊ฐ์ต๋๋ค. ์ ๊ฐ ๋๋ผ๊ธฐ์ ๋ ํ
๋ชจ๋ ๊ฐ์ ์ญํ ์ ํด์ฃผ๊ณ ์๋ ๊ฒ ๊ฐ์์ context๋ฅผ ์ธ์๋ก ๋ฐ๋๋ค๋ฉด ํ๋์ ํ
์ผ๋ก ํฉ์ณ์ ์ฌ์ฌ์ฉํด์ฃผ์ด๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค!ใ
ใ
|
@@ -0,0 +1,118 @@
+import { RULE } from "../constants/rules";
+import {
+ CART_ITEMS_COUNTS_ENDPOINT,
+ CART_ITEMS_ENDPOINT,
+ PRODUCTS_ENDPOINT,
+} from "./endpoints";
+import { fetchWithAuth } from "./fetchWithAuth";
+
+interface QueryParams {
+ [key: string]:
+ | undefined
+ | string
+ | number
+ | b... | TypeScript | ๋ชน์ ํฅ๋ฏธ๋ก์ด ํจ์๋ค์!๐๐ ๋ณ๊ฑฐ ์๋์ง๋ง ์ด๋ฌํ ๋ถ๋ถ์ api ๋ด๋ถ util๋ก ํ์ผ์ ๋ถ๋ฆฌํด์ฃผ์
๋ ์ข์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,118 @@
+import { RULE } from "../constants/rules";
+import {
+ CART_ITEMS_COUNTS_ENDPOINT,
+ CART_ITEMS_ENDPOINT,
+ PRODUCTS_ENDPOINT,
+} from "./endpoints";
+import { fetchWithAuth } from "./fetchWithAuth";
+
+interface QueryParams {
+ [key: string]:
+ | undefined
+ | string
+ | number
+ | b... | TypeScript | ์ถ์ํ๋ `fetchWithAuth` ๋ด๋ถ์์ ์ด๋ฏธ `response.ok`๊ฐ ์๋ ๊ฒฝ์ฐ ์๋ฌ๋ฅผ ๋์ง๋๋ก ์ฒ๋ฆฌํด๋์๋๋ฐ ์ฌ๊ธฐ๋ฅผ ํฌํจํ์ฌ ๋ชจ๋ fetch ํจ์์์ ์ฌ์ ํ ์๋ฌ๋ฅผ ๋์ง์๋ ์ด์ ๊ฐ ์์ผ์ค๊น์..?? |
@@ -26,11 +26,32 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
- compileOnly 'org.projectlombok:lombok'
+ implementation 'org.springframework.boot:spring-boot-starter-security'
+ ... | Unknown | Gradle ํ์์ด ์ผ์นํ์ง ์์ต๋๋ค.
๋ค๋ฅธ ๊ณณ๊ณผ ๋์ผํ๊ฒ ์กฐ์ ํด์ฃผ์ธ์.
```groovy
implementaion 'io.jsonwebtoken:jjwt-api:0.11.5'
``` |
@@ -0,0 +1,83 @@
+package io.study.springbootlayered.api.member.application;
+
+import java.security.SecureRandom;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.stream.Collectors;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transacti... | Java | `@Transactional` ์ด๋
ธํ
์ด์
์ ํด๋์ค ๋ ๋ฒจ๋ก ์ฌ๋ฆฌ๋๊ฒ ๋ง๋์ง์ ๋ํด์๋ ์๋ฌธ์ด ๋ญ๋๋ค.
- DB์ ์ ๊ทผํ์ง ์๋ ๋ฉ์๋๋ฅผ ์ํํ ๋๋ `@Transactional` ์ ์ํด ์๋ค๋ก ์ถ๊ฐ ๋ก์ง์ด ์คํ๋๋ฉฐ.
- readonly ๊ฐ ์๋ ๊ฒฝ์ฐ์ ์๋์์ ์ด์ฐจํผ ๋ ์ฌ์ฉํ๋์ง๋ผ ๋ถํ์ํ ์ฝ๋๊ฐ ๋์ด๋๋๊ฒ ์๋๊ฐ ์ถ์ต๋๋ค. |
@@ -0,0 +1,30 @@
+package io.study.springbootlayered.api.member.domain.dto;
+
+import java.util.List;
+
+import io.study.springbootlayered.api.member.domain.entity.AuthorityType;
+import io.study.springbootlayered.api.member.domain.entity.Member;
+import io.study.springbootlayered.api.member.domain.entity.MemberAuthori... | Java | Gradle ์ค์ ์ ์ํ๋ฉด Java ๋ฒ์ ์ด 21์ธ๋ฐ, ์ถฉ๋ถํ Record๋ก ๋์ฒด ๊ฐ๋ฅํ ์ฝ๋๋ก ๋ณด์
๋๋ค. |
@@ -0,0 +1,30 @@
+package io.study.springbootlayered.api.member.domain.dto;
+
+import java.util.List;
+
+import io.study.springbootlayered.api.member.domain.entity.AuthorityType;
+import io.study.springbootlayered.api.member.domain.entity.Member;
+import io.study.springbootlayered.api.member.domain.entity.MemberAuthori... | Java | Validation ์ ์ฌ์ฉํด์ ๋น๊ฐ์ด ๋ค์ด์ค์ง ์๋๋ก ํ๋ฉด ์ข๊ฒ ๋ค์. |
@@ -0,0 +1,19 @@
+package io.study.springbootlayered.api.member.domain.dto;
+
+import lombok.AccessLevel;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.RequiredArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public class MemberPasswordResetDto {
+
... | Java | ํ๋๊ฐ ๋๊ฐ์ธ๋ฐ ๊ตณ์ด ๋น๋๋ฅผ ์ฌ์ฉํด์ผ ํ๋ ์ถ์๋ฐ์,
๋น์ฅ ๋ฐ๋ก ์๋์ MemberSigninDto ์์๋ `@Builder`๊ฐ ์๋ค์. |
@@ -0,0 +1,19 @@
+package io.study.springbootlayered.api.member.domain.dto;
+
+import lombok.AccessLevel;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.RequiredArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public class MemberPasswordResetDto {
+
... | Java | ๋ชจ๋ Dto๊ฐ ๋ด๋ถ์ ์ผ๋ก ๋ Dto๋ฅผ ๊ฐ๊ณ ์๋ ์ด์ํ ๊ตฌ์กฐ๋ค์...
๊ทธ๋ฅ ์๋ก ๋ค๋ฅธ ํ์ผ๋ก ๋ถ๋ฆฌํ๋๊ฒ ๊ฐ๋
์ฑ ์ธก๋ฉด์์ ๋ ๋ซ์ง ์์๊น์?
ํนํ๋ ๋ด๋ถ์ ์ผ๋ก ๊ฐ์ ์ด๋ฆ์ ์ฐ๊ณ ์๊ธฐ ๋๋ฌธ์, ํ์ฌ๋ ์ค์๋ก Static Import๋ฅผ ํ๋ ์๊ฐ ์ด๊ฒ ์ด๋์์ ์จ๊ฑด์ง ํ์
ํ ๋ฐฉ๋ฒ์ด ์์ ์์ด์ง๋๋ค. |
@@ -0,0 +1,83 @@
+package io.study.springbootlayered.api.member.application;
+
+import java.security.SecureRandom;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.stream.Collectors;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transacti... | Java | ๊ฒฐ๊ตญ `SpecialCharactes` ์ `ValidCharacters` ์ ์กฐํฉ์ผ๋ก ๊ตฌ์ฑ๋๋ค๊ณ ๋ณผ ์ ์๊ฒ ๋ค์.
- ์ด์ฐจํผ ๋ฌธ์์ด ์๋๊ฑด ๋๊ฐ์ต๋๋ค.
```java
private String createRandomString(String baseStr, int length) {
return random.ints(length, 0, baseStr.length())
.mapToObj(baseStr::charAt)
.collect(StringBuilder::new, StringBuilde... |
@@ -0,0 +1,83 @@
+package io.study.springbootlayered.api.member.application;
+
+import java.security.SecureRandom;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.stream.Collectors;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transacti... | Java | ๋งค๋ฒ Random ๊ฐ์ฒด๋ฅผ ์์ฑํ์ง ๋ง๊ณ , ๊ทธ๋ฅ ์ต์๋จ์ private final ๋ก ์ฌ๋ ค๋ฒ๋ฆฌ์ธ์.
`private final Random random = new SecureRandom();` |
@@ -0,0 +1,32 @@
+package io.study.springbootlayered.api.member.application;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import io.study.springbootlayered.api.member.domain.MemberProcessor;
+import io.study.springbootlayered.api.member.domain.dt... | Java | ์ธ๋ผ์ธ ์ฃผ์์ // ๊ฐ ์ข๊ฒ ์ฃ ? |
@@ -0,0 +1,23 @@
+package io.study.springbootlayered.api.member.domain.entity;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+
+@Embeddable
+@Getter
+@EqualsAndHashCode
+public class MemberPassword {
+
+ @Column(name = "password... | Java | ์์๋ Equals์ hashCode๋ฅผ ์ง์ ์ ์ํ๋๋, ์ด๋ฒ์๋ ๋กฌ๋ณต์ ์ฌ์ฉํ๋ค์? |
@@ -0,0 +1,42 @@
+package io.study.springbootlayered.api.member.domain.event;
+
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.event.TransactionalEventListener;
+
+import io.study.springbootlayered.infra.mail.MailService... | Java | ์ผ๋ฐ์ ์ผ๋ก ๊ฐ๋ฐ ํ๊ฒฝ์์๋ log level์ debug๋ก, ์ด์ ํ๊ฒฝ์์๋ info/warn ์์ค์ผ๋ก ์ค์ ํฉ๋๋ค.
์ด์ ํ๊ฒฝ์์ ํด๋น ์์ฒญ์ด ๋ค์ด์ฌ "๋ ๋ง๋ค" ํด๋น ๋ก๊ทธ๊ฐ ์ถ๋ ฅ๋๊ฒ ๋๋ฉด, ์๋ฌ ๋๋ฒ๊น
๊ณผ์ ์์ ๋งค์ฐ ๋ฒ๊ฑฐ๋ก์์ง ํ๋ฅ ์ด ๋์ต๋๋ค.
๊ฐ๋ฐ ๊ณผ์ ์์์ ๋๋ฒ๊น
์ฉ์ธ์ง, ์ด์ ํ๊ฒฝ์์ ์ค์ ๋ก ํ์ํ ๋ก๊ทธ์ธ์ง ์ ์๊ฐํด๋ณด์๊ณ ๋ก๊ทธ ๋ ๋ฒจ์ ์ง์ ํ๋๊ฒ ์ข์ต๋๋ค. |
@@ -0,0 +1,15 @@
+package io.study.springbootlayered.api.member.domain.event;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+@Getter
+@RequiredArgsConstructor
+public class SignupEvent {
+
+ private final String email;
+
+ public static SignupEvent of(String email) {
+ return new Signu... | Java | ์์ฑ์๋ ์ญํ ์ด ๋๊ฐ๋ค์. |
@@ -0,0 +1,63 @@
+package io.study.springbootlayered.api.member.domain;
+
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Component;
+
+import io.study.springbootlayered.api.member.domain.dto.MemberDetailDto;
+import io.study.springbootlayered.api.member.doma... | Java | ~~Impl ํ์์ ํด๋์ค์ ์กด์ฌ ์ฌ๋ถ๋ฅผ ์ดํดํ๊ธด ์ด๋ ต๋ค์.
- ๋ค๋ฅธ ๊ตฌํ์ฒด์ ๊ฐ๋ฅ์ฑ์ด ์กด์ฌํ๋์?
- ์์ ๋ค๋ฅธ Processor๋ ๋ง์ ํ ํด๋์ค๋ฅผ ์์ํ๋ ๊ตฌ์กฐ๋ผ Impl์ ์ ๋ฌ๊ณ ์๋ค์. |
@@ -0,0 +1,63 @@
+package io.study.springbootlayered.api.member.domain;
+
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Component;
+
+import io.study.springbootlayered.api.member.domain.dto.MemberDetailDto;
+import io.study.springbootlayered.api.member.doma... | Java | ํด๋น ์ฟผ๋ฆฌ๊ฐ ๋ค๋ฅธ ๊ณณ์์ ์ฌ์ฌ์ฉ๋์ง ์์ ๊ฒ์ด๋ผ๋ ๋ณด์ฅ์ด ์๋์?
์ด๋ฐ ๊ธฐ๋ณธ์ ์ธ Validation ์ฉ ์ฟผ๋ฆฌ๋ ๋ถ๋ฆฌํด์ ๋ค๋ฃจ๋๊ฒ ์ข์ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,32 @@
+package io.study.springbootlayered.api.member.application;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import io.study.springbootlayered.api.member.domain.MemberProcessor;
+import io.study.springbootlayered.api.member.domain.dt... | Java | ๋ก๊ทธ ๋ฏธ์ฌ์ฉ์ธ๋ฐ ํด๋น ์ด๋
ธํ
์ด์
์ฌ์ฉํ๊ณ ์๋ค์. |
@@ -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,185 @@
+package pairmatching.controller;
+
+import java.util.function.Function;
+import org.mockito.internal.util.Supplier;
+import pairmatching.enums.Course;
+import pairmatching.enums.Crew;
+import pairmatching.enums.Functions;
+import pairmatching.enums.Level;
+import pairmatching.enums.Missions;
+import ... | Java | ```suggestion
if (Functions.isEquals(input, Functions.QUIT)) {
performFunctions(input, inputView);
return
}
```
์ฌ์ํ๊ฑฐ์ง๋ง return์ ์ฌ์ฉํ๋ค๋ฉด ์๋์ if๋ฌธ์ ์๋ง๋ค๊ณ ์ฒ๋ฆฌํ ์ ์์์ ๊ฑฐ ๊ฐ์์ |
@@ -0,0 +1,34 @@
+package pairmatching.model;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class Pairs {
+
+ private Map<String, List<String>> pairs;
+
+ public Pairs(Map<String, List<String>> pair){
+ this.pairs = pair;
+ }
+
+ public Set<Map.Entry<String, List<S... | Java | for-each์ string Joiner๋ฅผ ์จ์ ํด๊ฒฐํ์ด๋ ๋์๊ฑฐ ๊ฐ์์! |
@@ -0,0 +1,89 @@
+package store.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+import store.model.Order;
+import store.model.Promotion;
+import store.model.Receipt;
+import store.model.Store;
+import store.service.StoreService;
+import store.view.InputView;
+import store.view.OutputView;
+
+public ... | Java | order๋ฅผ do ๋ด๋ถ์์ ์ ์ธํ๋ ๊ฒ์ด ๋ ๊น๋ํ์ง ์์๊น ์๊ฐ์ด ๋๋ค์..!
checkEnd() ๋ด๋ถ์ updateStore() ๋ฅผ do ๊ตฌ๋ฌธ ๋ด๋ถ๋ก ์ด๋์ํจ๋ค๋ฉด ๊ฐ๋ฅํ ๊ฒ ๊ฐ์ต๋๋ค..! |
@@ -0,0 +1,59 @@
+package store.model;
+
+import static store.utils.ErrorMessage.INVALID_FORMAT;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Order {
+ private List<Product> order;
+
+ public Order(String inputOrder) {
+ validateProductFormat(inputOrder);
+ this.order = gen... | Java | replaceAll() ์ด๋ผ๋ ๋ฉ์๋๋ก๋ ๊ฐ์ ๊ธฐ๋ฅ์ ๊ตฌํํ ์ ์์ต๋๋ค!
์ด๋ฏธ ์์ค์๋ ์์ง๋ง ํน์๋ ํด์ ๋ง์๋๋ฆฝ๋๋ค..! |
@@ -0,0 +1,73 @@
+package store.model;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class Promotion {
+ private String name;
+ private int buy;
+ priv... | Java | `now.after(startDate) && now.before(endDate)` ๋ ๊ฐ์ ์๋ฏธ์ธ๋ฐ
ํ์ฌ ์ฝ๋์ฒ๋ผ ์์ฑํ์ ์ด์ ๊ฐ ์์ผ์ค๊น์?
๊ถ๊ธํด์ ์ง๋ฌธ๋๋ฆฝ๋๋ค..! |
@@ -0,0 +1,294 @@
+package store.service;
+
+import static store.model.Promotion.parsePromotions;
+import static store.model.Store.*;
+import static store.utils.ErrorMessage.INVALID_INPUT;
+import static store.utils.ErrorMessage.INVALID_NAME;
+import static store.utils.ErrorMessage.INVALID_QUANTITY;
+
+import java.io.B... | Java | ํ์ผ๋ช
์ ์์๋ก ์ฌ์ฉํ๋ค๋ฉด ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,294 @@
+package store.service;
+
+import static store.model.Promotion.parsePromotions;
+import static store.model.Store.*;
+import static store.utils.ErrorMessage.INVALID_INPUT;
+import static store.utils.ErrorMessage.INVALID_NAME;
+import static store.utils.ErrorMessage.INVALID_QUANTITY;
+
+import java.io.B... | Java | ๋ฆฌํฉํ ๋งํ๋ค๋ฉด ์ฌ๊ธฐ ์ํ์ ์๋์ ๊ตฌํ๋ ๋ถ๋ถ์
ํ๋์ ๋ฉ์๋๋ก ๋ถ๋ฆฌํ์๋ ๊ฒ๋ ์ข๊ฒ ๋ค์ |
@@ -0,0 +1,294 @@
+package store.service;
+
+import static store.model.Promotion.parsePromotions;
+import static store.model.Store.*;
+import static store.utils.ErrorMessage.INVALID_INPUT;
+import static store.utils.ErrorMessage.INVALID_NAME;
+import static store.utils.ErrorMessage.INVALID_QUANTITY;
+
+import java.io.B... | Java | ์๋ฐ ํ์ผ ์
์ถ๋ ฅ์ ์ฌ๋ฌ ๋ฐฉ๋ฒ์ด ์๋๋ฐ ๋ฒํผ๋ฆฌ๋ ํ์์ ์ฌ์ฉํ์ ์ด์ ๊ฐ ์์ผ์ค๊น์?? |
@@ -0,0 +1,294 @@
+package store.service;
+
+import static store.model.Promotion.parsePromotions;
+import static store.model.Store.*;
+import static store.utils.ErrorMessage.INVALID_INPUT;
+import static store.utils.ErrorMessage.INVALID_NAME;
+import static store.utils.ErrorMessage.INVALID_QUANTITY;
+
+import java.io.B... | Java | ํด๋น ๋ฉ์๋๋ ์๋น์ค๊ฐ ํ๋ ๊ธฐ๋ฅ ๋ณด๋ค๋ ๋ค๋ฅธ ํด๋์ค๋ก ์ฎ๊ธฐ๋๊ฒ ๋ ์ ํฉํด๋ณด์
๋๋ค..! |
@@ -0,0 +1,294 @@
+package store.service;
+
+import static store.model.Promotion.parsePromotions;
+import static store.model.Store.*;
+import static store.utils.ErrorMessage.INVALID_INPUT;
+import static store.utils.ErrorMessage.INVALID_NAME;
+import static store.utils.ErrorMessage.INVALID_QUANTITY;
+
+import java.io.B... | Java | ์ด ๋ถ๋ถ๋ ๋์ค์ receiptservice๋ก ๋ถ๋ฅํ๋ฉด ์ด๋จ๊น์..? |
@@ -0,0 +1,294 @@
+package store.service;
+
+import static store.model.Promotion.parsePromotions;
+import static store.model.Store.*;
+import static store.utils.ErrorMessage.INVALID_INPUT;
+import static store.utils.ErrorMessage.INVALID_NAME;
+import static store.utils.ErrorMessage.INVALID_QUANTITY;
+
+import java.io.B... | Java | Math.min์ ์ฌ์ฉํ์๋ฉด ํ์ค๋ก ๋ง๋ค์์์๊ฑฐ๊ฐ์์ |
@@ -0,0 +1,14 @@
+package store.utils;
+
+public class ErrorMessage {
+ public static final String ERROR = "[ERROR] ";
+ public static final String RETRY = " ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.";
+ public static final String INVALID_FORMAT = " ์ฌ๋ฐ๋ฅด์ง ์์ ํ์์ผ๋ก ์
๋ ฅํ์ต๋๋ค. ";
+ public static final String INVALID_NAME = " ์กด์ฌํ์ง ์๋ ์ํ์
๋๋ค.";
+... | Java | enum์ ์ฌ์ฉํ์ง ์๊ณ class๋ก ๋ถ๋ฆฌํ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค |
@@ -0,0 +1,89 @@
+package store.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+import store.model.Order;
+import store.model.Promotion;
+import store.model.Receipt;
+import store.model.Store;
+import store.service.StoreService;
+import store.view.InputView;
+import store.view.OutputView;
+
+public ... | Java | ํจ์๋ช
์ ๋์ฌ๋ก ํ๋ ๊ฑด ์ด๋จ๊น์?? ์๋ฅผ ๋ค์ด `calculatePrice` ์ฒ๋ผ ๋ง์ด์ฃ !! |
@@ -0,0 +1,91 @@
+package store.model;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class Store {
+ private final String name;
+ private int price;
+ private int quantity;
+ private String promotion;
+
+ public Store(String name, int price, int quantity, String promotion) {
+ this... | Java | ๊ฐ๊ฐ์ ์ธ๋ฑ์ค๊ฐ ์ด๋ค ๊ฒ์ ์๋ฏธํ๋์ง ์์ํ ํ์ผ๋ฉด ๋ ์ข์์ ๊ฒ ๊ฐ์ต๋๋ค!!! |
@@ -0,0 +1,73 @@
+package store.model;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class Promotion {
+ private String name;
+ private int buy;
+ priv... | Java | ๋ฌธ์์ด์ ํ๋ก๋ชจ์
์ผ๋ก ํ์ฑํ๋ ์ญํ ์ ํ์ฑํ๋ ๊ฐ์ฒด๋ฅผ ๋ง๋ค์ด์ ๊ฑฐ๊ธฐ๋ก ๋๊ธฐ๋๊ฑด ์ด๋จ๊น์!! |
@@ -0,0 +1,294 @@
+package store.service;
+
+import static store.model.Promotion.parsePromotions;
+import static store.model.Store.*;
+import static store.utils.ErrorMessage.INVALID_INPUT;
+import static store.utils.ErrorMessage.INVALID_NAME;
+import static store.utils.ErrorMessage.INVALID_QUANTITY;
+
+import java.io.B... | Java | answer์ enum ์์๋ก ๋ง๋๋ ๊ฒ์ ์ด๋จ๊น์? |
@@ -0,0 +1,59 @@
+package store.model;
+
+import static store.utils.ErrorMessage.INVALID_FORMAT;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Order {
+ private List<Product> order;
+
+ public Order(String inputOrder) {
+ validateProductFormat(inputOrder);
+ this.order = gen... | Java | ๊ฐ์ธ์ ์ผ๋ก ์์ ์ ๋ค [ ] ํ์ธํ๋ ๋ถ๋ถ๊ณผ ๋น๋ฌธ์์ด์ธ์ง ํ์ธํ๋ ๋ก์ง์ ๋ถ๋ฆฌํด๋ ๋ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,50 @@
+package store.model;
+
+public class Receipt {
+ private String name;
+ private int individualPrice;
+ private int quantity;
+ private int promotionQuantity;
+ private int promotionBuy;
+
+ public Receipt(String name, int individualPrice, int quantity, int promotionBuy) {
+ th... | Java | ์ด๋ฒ ๊ณผ์ ์์ ๊ฒํฐ ์ฌ์ฉ์ ์ค์ด๊ธฐ๊ฐ ์ฝ์ง ์์, ์ ๋ ๊ฒฐ๊ตญ ์ฌ์ฉํ ์๋ฐ์ ์์์ต๋๋คใ
ใ
๊ฒํฐ๋ฅผ ์ฌ์ฉํ๋ฉด ๊ฐ์ฒด์ ์บก์ํ๋ฅผ ์๋ฐํ ์ํ์ด ์๊ณ , ๊ฐ์ฒด์ ์ํ๋ฅผ ์ธ๋ถ์์ ์ฝ๊ฒ ๋ณ๊ฒฝํ ์ ์๊ฒ ๋์ด ๊ฐ์ฒด์ ์ฑ
์์ด ์ธ๋ถ๋ก ๋ฐ๋ ค๋ ์ ์๊ธฐ ๋๋ฌธ์ ์ง์ํด์ผ ํ๋ค๊ณ ์๊ณ ์์ต๋๋ค.
๊ทธ๋์ ์์ผ๋ก ๊ฒํฐ ์ฌ์ฉ์ ์ค์ด๊ธฐ ์ํด DTO๋ฅผ ํ์ฉํด๋ณด๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ด ๋ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,294 @@
+package store.service;
+
+import static store.model.Promotion.parsePromotions;
+import static store.model.Store.*;
+import static store.utils.ErrorMessage.INVALID_INPUT;
+import static store.utils.ErrorMessage.INVALID_NAME;
+import static store.utils.ErrorMessage.INVALID_QUANTITY;
+
+import java.io.B... | Java | ์๋น์ค์์ View๋ฅผ ํธ์ถํ๋๊ฑด ๊ฐ์ธ์ ์ผ๋ก layered architecture๊ตฌ์กฐ์ ์ ํฉํ์ง ์๋ค๊ณ ์๊ฐ๋ฉ๋๋ค!
Layered architecture๋ ๊ด์ฌ์ฌ๋ณ๋ก ๊ณ์ธต์ ๋๋ ๊ตฌ์กฐ๋ก ์๊ณ ์์ต๋๋ค. Presentation Layer ๋ ์ฌ์ฉ์์์ ์ํธ์์ฉ์ ๋ด๋นํ๋ ์ญํ , business Layer ๋ ๋น์ง๋์ค ๋ก์ง๋ง ๋ด๋นํ๋ ์ญํ ์
๋๋ค. ๋ฐ๋ผ์ View ๊ฐ์ฒด๋ค์ presentation layer ์ ์ํ๋ค๊ณ ๋ณผ ์ ์์ต๋๋ค.
ํ์ง๋ง ํ์ฌ ์ฝ๋๋ฅผ ๋ณด๋ฉด business layer ๊ฐ presentation layer ๋ฅผ ์์กดํ๋ ๊ฒ์ผ๋ก ๋ณด์ด๋๋ฐ, ์ด๋ ๊ฒ... |
@@ -0,0 +1,86 @@
+package store.view;
+
+import static store.utils.ErrorMessage.ERROR;
+import static store.utils.ErrorMessage.RETRY;
+
+import java.util.List;
+import store.model.Receipt;
+import store.model.Store;
+
+public class OutputView {
+ private static final String ERROR_ANSWER = "[ERROR] ์๋ชป๋ ์
๋ ฅ์
๋๋ค. ๋ค์ ์
๋ ฅํด ... | Java | ์ด ๋ถ๋ถ์ ์์๋ก ์ฒ๋ฆฌํ์ง ์์ ์ด์ ๊ฐ ์์๊น์? |
@@ -0,0 +1,89 @@
+package store.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+import store.model.Order;
+import store.model.Promotion;
+import store.model.Receipt;
+import store.model.Store;
+import store.service.StoreService;
+import store.view.InputView;
+import store.view.OutputView;
+
+public ... | Java | do while๋ฌธ์ ์ฒ์ ์ฌ์ฉํด์ ์ ๋ชฐ๋๋๋ฐ ์์์ ์ ์ธํ๋ ๋ฐฉ๋ฒ์ ์๊ฐ๋ ๋ชปํ๋ค์ ๋ฐฐ์๊ฐ๋๋ค! |
@@ -0,0 +1,73 @@
+package store.model;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class Promotion {
+ private String name;
+ private int buy;
+ priv... | Java | ๊ฐ๋
์ฑ์ด ๋ ์ข๋ค๊ณ ์๊ฐ๋๋ ๋ฐฉํฅ์ผ๋ก ์์ฑํ์ต๋๋ค |
@@ -0,0 +1,294 @@
+package store.service;
+
+import static store.model.Promotion.parsePromotions;
+import static store.model.Store.*;
+import static store.utils.ErrorMessage.INVALID_INPUT;
+import static store.utils.ErrorMessage.INVALID_NAME;
+import static store.utils.ErrorMessage.INVALID_QUANTITY;
+
+import java.io.B... | Java | readLine() ์ ์ฌ์ฉํ์ฌ ํ ์ค์ฉ ์ฝ๊ธฐ ์ข๋ค๊ณ ์๊ฐํ์ฌ ์ฌ์ฉํ์ต๋๋ค |
@@ -0,0 +1,14 @@
+package store.utils;
+
+public class ErrorMessage {
+ public static final String ERROR = "[ERROR] ";
+ public static final String RETRY = " ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.";
+ public static final String INVALID_FORMAT = " ์ฌ๋ฐ๋ฅด์ง ์์ ํ์์ผ๋ก ์
๋ ฅํ์ต๋๋ค. ";
+ public static final String INVALID_NAME = " ์กด์ฌํ์ง ์๋ ์ํ์
๋๋ค.";
+... | Java | ๊ฐ๋ค์ ๊ทธ๋ฃนํ ํ์ฌ ์ฌ์ฉํ์ง ์๊ณ ๋จ์ ๋ฉ์ธ์ง ์ถ๋ ฅ์ด๊ธฐ์ ์์ ํด๋์ค๋ก ํด๋ ์ข์ ๊ฒ ๊ฐ๋ค๊ณ ์๊ฐํ์ต๋๋ค |
@@ -0,0 +1,73 @@
+package store.model;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class Promotion {
+ private String name;
+ private int buy;
+ priv... | Java | ์ญํ ๋ถ๋ฆฌ๋ฅผ ์ข ๋ ์์ธํ ํด์ผ ๋ ๊ฒ ๊ฐ๋ค์.. ์ฐธ๊ณ ํ๊ฒ ์ต๋๋ค! |
@@ -0,0 +1,50 @@
+package store.model;
+
+public class Receipt {
+ private String name;
+ private int individualPrice;
+ private int quantity;
+ private int promotionQuantity;
+ private int promotionBuy;
+
+ public Receipt(String name, int individualPrice, int quantity, int promotionBuy) {
+ th... | Java | ๋ง์ํ์ ๋ด์ฉ ๋ฃ๊ณ ์ ์ฝ๋๋ฅผ ๋ค์ ์ดํด๋ณด๋, ๊ฐ์ฒด๋ด์์๋ ๋จ์ํ ๋ฐ์ดํฐ๋ง ๋ด์๋๊ณ ๊ฒํฐ ์ฌ์ฉ์ผ๋ก ๋๋ถ๋ถ ์ธ๋ถ์์ ๋ก์ง์ ์ฒ๋ฆฌํ์ฌ ๊ฐ์ฒด์งํฅ์ ์๋ฏธ๋ฅผ ์์ ์ฝ๋๋ฅผ ์์ฑํ ๊ฒ ๊ฐ์ต๋๋ค...
๊ตฌํํ๋๋ฐ ๋๋ฌด ๊ธ๊ธํ๋๊ฑฐ๊ฐ๋ค์ใ
ใ
ํผ๋๋ฐฑ ๊ฐ์ฌํฉ๋๋ค |
@@ -0,0 +1,294 @@
+package store.service;
+
+import static store.model.Promotion.parsePromotions;
+import static store.model.Store.*;
+import static store.utils.ErrorMessage.INVALID_INPUT;
+import static store.utils.ErrorMessage.INVALID_NAME;
+import static store.utils.ErrorMessage.INVALID_QUANTITY;
+
+import java.io.B... | Java | OutputView ํด๋์ค์์ ์ ์ผํ๊ฒ ์์ฑํ ์คํํฑ ๋ฉ์๋ ์
๋๋ค.
์ ๋ ๊ตฌํํ๋ ๊ณผ์ ์์ ์ณ์ง ์๋ค๊ณ ์๊ฐํ์ง๋ง,
๋น์ฆ๋์ค ๋ก์ง์ ์ฒ๋ฆฌํ๋ ๊ณผ์ ์์ ์ณ์ง ์์ ์
๋ ฅ์ด ์์ ๋ outputView ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐ ํ ๋ฐฉ๋ฒ์ด ๋ ์ค๋ฅด์ง ์์ ์ด๋ ๊ฒ ์์ฑํ๊ฒ ๋์ต๋๋ค..
์ ํฉํ์ง ์์ ์ด์ ๋ฅผ ์์ธํ๊ฒ ๋ง์ํด ์ฃผ์
์ ์๋กญ๊ฒ ํ๋ ๋ ๋ฐฐ์๊ฐ๋๋ค ๊ฐ์ฌํฉ๋๋ค..! |
@@ -0,0 +1,16 @@
+package store.constant;
+
+public enum CommonMessage {
+ YES("Y"),
+ NO("N");
+ private final String commonMessage;
+
+ CommonMessage(final String commonMessage) {
+ this.commonMessage = commonMessage;
+ }
+
+ public String getCommonMessage() {
+ return commonMessage;
+... | Java | ์
๋ ฅ์ด ๋๋ฟ์ธ ๊ฒฝ์ฐ์ ๋ํด์ Enum์ผ๋ก ๊ด๋ฆฌํ๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ธ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,22 @@
+package store.constant;
+
+public enum FileMessage {
+ PRODUCTS_FILE_NAME("products.md"),
+ PROMOTION_FILE_NAME("promotions.md"),
+ NULL("null"),
+ SOFT_DRINK("ํ์ฐ2+1"),
+ MD_RECOMMEND_PRODUCT("MD์ถ์ฒ์ํ"),
+ FLASH_DISCOUNT("๋ฐ์งํ ์ธ"),
+ FILE_START_WORD("name");
+
+ private final Stri... | Java | ํ์ผ์ ์๋ ํ๋ก๋ชจ์
๋ฐ์ดํฐ๋ฅผ Enum์ผ๋ก ๊ด๋ฆฌํ๋๊ฑด ์ข์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค
ํ๋ก๋ชจ์
์ข
๋ฅ๊ฐ 3๊ฐ ๊ณ ์ ์ด ์๋๋ผ ๊ฐ๊ธฐ ๋ค๋ฅธ ์๋ฐฑ ๊ฐ, ์์ฒ ๊ฐ๋ก ๋์ด๋ ์ ์์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,71 @@
+package store.domain;
+
+import java.util.ArrayList;
+import java.util.List;
+import store.constant.CommonMessage;
+import store.constant.CommonValue;
+
+public class Receipt {
+ private final double THIRTY_PERCENT = 0.3;
+ private final List<ReceiptItem> receiptItems = new ArrayList<>();
+
+ ... | Java | model์ ์ญํ ์ ์ํํ๋ ํด๋์ค๋ก ๋ณด์ด๋๋ฐ ํจํค์ง๋ฅผ ๋ถ๋ฆฌํ์ง ์๊ณ , domain ํจํค์ง์ ๊ฐ์ด ๋์ ์ด์ ๊ฐ ์์๊น์? |
@@ -0,0 +1,143 @@
+package store.controller;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.util.List;
+import java.util.function.Supplier;
+import store.constant.CommonMessage;
+import store.constant.CommonValue;
+import store.constant.SignMessage;
+import store.domain.GeneralProduct;
+import store.d... | Java | `userMembership()`์์ ๋ฉค๋ฒ์ญ ํ ์ธ ์ฌ๋ถ์ ๋ฐ๋ผ ์ต์ข
๊ณ์ฐ ๊ธ์ก์์ 30% ํ ์ธ์ด ๋๊ณ ์๋๋ฐ,
์๊ตฌ์ฌํญ์์๋ ํ๋ก๋ชจ์
์ํ์ ์ ์ธํ ์ผ๋ฐ ์ํ์ผ๋ก ๊ฒฐ์ ๋ ์ํ๋ค์ ๋ํด์๋ง ๋ฉค๋ฒ์ญ ํ ์ธ์ด ๋์ด์ผ ํ๋ค๊ณ ๋ช
์๋์ด ์์ต๋๋ค
์ด ๋ถ๋ถ์ด ์ฒ๋ฆฌ๋์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,19 @@
+package store.constant;
+
+public enum CommonValue {
+ ZERO(0),
+ ONE(1),
+ TWO(2),
+ EIGHT_THOUSAND(8000);
+
+ private final int value;
+
+ CommonValue(final int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+} | Java | ์์๋ค์ enum์ผ๋ก ์ ๊ด๋ฆฌํด์ฃผ์
จ๋๋ฐ์!
์ ๋ ๊ฐ์ธ์ ์ผ๋ก enum์ ๊ฐ์ ๊บผ๋ด๊ธฐ ์ํด `.getValue()` ๊น์ง ๋ถ๋๊ฒ ์กฐ๊ธ ์ง์ ๋ถํด๋ณด์
๋๋ค.
static ์์์ ๊ฒฝ์ฐ `Constant.ZERO` ์ด๋ฐ์์ผ๋ก ์ฌ์ฉํ ์ ์์ง๋ง enum์ `CommonValue.ZERO.getValue()` ๋ก 1depth ๋ ๋์ด๋๋ ๋๋์ด๋๊น์..? |
@@ -0,0 +1,71 @@
+package store.domain;
+
+import java.util.ArrayList;
+import java.util.List;
+import store.constant.CommonMessage;
+import store.constant.CommonValue;
+
+public class Receipt {
+ private final double THIRTY_PERCENT = 0.3;
+ private final List<ReceiptItem> receiptItems = new ArrayList<>();
+
+ ... | Java | int๋ฅผ double๊ณผ ๊ณฑํ ๋ค int๋ก ํ๋ณํ์ ํ๊ณ ์๋๋ฐ์!
double๋ก ๊ณ์ฐ๋๋ ๊ณผ์ ์์ ๋ถ๋์์์ ์ค๋ฅ๋ฅผ ํผํ ์ ์์ ๊ฒ์ผ๋ก ๋ณด์
๋๋ค. ์ด๋๋ `* 30 / 100` ์ผ๋ก ๊ณ์ฐํด์ ์์ ์์์ ์ด ์์๊ธฐ๋๋ก ๊ณ์ฐํ์๋ ๊ฒ์ ์ด๋จ๊น์? |
@@ -0,0 +1,143 @@
+package store.controller;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.util.List;
+import java.util.function.Supplier;
+import store.constant.CommonMessage;
+import store.constant.CommonValue;
+import store.constant.SignMessage;
+import store.domain.GeneralProduct;
+import store.d... | Java | ์ ๋ MVC ํจํด์ Service ๊ณ์ธต์ ์ถ๊ฐํด์ ์ฑ
์ ๋ถ๋ฆฌ์ ์ ๋จน์์๋๋ฐ, Service๊ฐ ์์ผ๋ ์ข ๋ ์์ฐ์ค๋ฝ๊ฒ ๋ฐ์ดํฐ ์ ๋ฌ์ด ์ด๋ฃจ์ด์ง๋ค์..!! |
@@ -0,0 +1,141 @@
+package store.view.output;
+
+import java.util.List;
+import store.domain.GeneralProduct;
+import store.domain.PromotionProduct;
+import store.domain.Receipt;
+import store.domain.ReceiptItem;
+import store.domain.Storage;
+import store.exception.ConvenienceStoreException;
+
+public class OutputView ... | Java | ํ๋ก๋ชจ์
์ํ์ด ์์ง๋๊ณ ๋์ ํ๋ก๋ชจ์
์ํ๋ ์ฌ๊ณ ์์์ผ๋ก ์ถ๋ ฅ๋๋๋ฐ,
์ฌ์ฉ์๋ ํ๋ก๋ชจ์
์ํ์ ๊ตฌ๋งคํ ์ ์์ผ๋ฏ๋ก ์์ ๋
ธ์ถ์ํค์ง ์๋ ๊ฒ๋ ์ข์ ๊ฒ ๊ฐ์์!
UX์ชฝ์ผ๋ก๋ ํ๋ฒ ๊ณ ๋ฏผํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค๐ |
@@ -0,0 +1,38 @@
+package store.domain;
+
+public class GeneralProduct {
+ private final String name;
+ private final String price;
+ private int quantity;
+
+ public GeneralProduct(final String name, final String price, final int quantity) {
+ this.name = name;
+ this.price = price;
+ ... | Java | ๊ฐ์ธ์ ์ธ ๊ถ๊ธ์ฆ์ผ๋ก ์ฌ์ญค๋ด
๋๋ค
`price`๋ฅผ `String` ์ผ๋ก ๊ด๋ฆฌํ์ ํน๋ณํ ์ด์ ๊ฐ ์์ผ์ค๊น์? |
@@ -0,0 +1,143 @@
+package store.controller;
+
+import camp.nextstep.edu.missionutils.DateTimes;
+import java.util.List;
+import java.util.function.Supplier;
+import store.constant.CommonMessage;
+import store.constant.CommonValue;
+import store.constant.SignMessage;
+import store.domain.GeneralProduct;
+import store.d... | Java | `HYPHEN`์ด๋ `ZERO` ๊ฐ์ด ์ด๋ฆ ์์ฒด๊ฐ ์๋ฏธ๋ฅผ ์ง๊ด์ ์ผ๋ก ๋ด๊ณ ์๋ ๊ฒฝ์ฐ๋
enum๋ณด๋ค ์ผ๋ฐ ํด๋์ค๋ฅผ ์ฌ์ฉํด์ `getValue()`๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ง ์๋ ํธ์ด ์กฐ๊ธ ๋ ๊น๋ํ์ง ์์๊น์..? |
@@ -0,0 +1,40 @@
+package store.domain;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+public class Promotion {
+ private final String name;
+ private final int buy;
+ private final int get;
+ private final LocalDate startDate;
+ private final LocalDate endDate;
+
+ public Promotio... | Java | ์กฐ๊ฑด๋ถ๊ฐ ๊ธธ๋ค๋ณด๋๊น ๋ ์ง๊ฐ ๊ธฐ๊ฐ์ ํฌํจ๋๋์ง ํ์ธํ๋ ๋ฉ์๋๋ฅผ ๊ตฌํํ๋ ๊ฒ๋ ๋์์ง ์๋ค๊ณ ์๊ฐ์ด ๋ค์์ต๋๋ค
```
boolean isBetween(LocalDate date) {
return !date.isBefore(startDate) && !date.isAfter(endDate);
}
``` |
@@ -0,0 +1,83 @@
+package store.domain;
+
+import java.util.Collections;
+import java.util.List;
+import store.constant.CommonValue;
+import store.constant.SignMessage;
+import store.exception.ConvenienceStoreException;
+import store.exception.ErrorMessage;
+
+public class Storage {
+ private final List<GeneralProdu... | Java | `Unmodifiable Collection`์ ์ฌ์ฉํ์
์
์ธ๋ถ์ ๋ณํ์ ๋ง์ผ์ ์ ๋๋ฌด ์ข์ต๋๋ค..! |
@@ -0,0 +1,114 @@
+package store.service;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import store.constant.FileMessage;
+import store.constant.SignMessage;
+import store.domain.GeneralProduct;
+import store.domain.Promotion;
+import store.domain.PromotionProduct;
+import store.... | Java | ์ด ์์๋ `ErrorMessage` ํด๋์ค์ ํฌํจ๋์ง ์์ ์ด์ ๊ฐ ํน์ ์์๊น์? |
@@ -0,0 +1,16 @@
+package store.constant;
+
+public enum CommonMessage {
+ YES("Y"),
+ NO("N");
+ private final String commonMessage;
+
+ CommonMessage(final String commonMessage) {
+ this.commonMessage = commonMessage;
+ }
+
+ public String getCommonMessage() {
+ return commonMessage;
+... | Java | ๊ฐ์ฌํฉ๋๋ค!
ํน์ ๋ฒ์์ ๊ฐ๋ง ์ฌ์ฉ์ ํ๋๊น enum์ผ๋ก ์ฌ์ฉํด๋ณผ๊น? ์๊ฐํด๋ดค์ด์! |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.