code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -0,0 +1,61 @@
+package baseball;
+
+import java.util.List;
+
+public class Referee {
+
+ public int countBall(List<Integer> list1, List<Integer> list2) {
+
+ int count = 0;
+ int strike = countStrike(list1, list2);
+
+ for (Integer number : list1) {
+ count = getCount(list2, count,... | Java | Referee ํด๋์ค์ ์ธ์คํด์ค๋ ์ด๋ค ์ํ(๋ด๋ถ ํ๋)๋ ๊ฐ์ง์ง ์๊ธฐ ๋๋ฌธ์ ์ด ํด๋์ค์ ๋ชจ๋ ๊ฐ์ฒด๋ค์ ๋์ผํ ๊ฐ์ฒด์ด๊ฒ ๋ค์ !
๋๋ฌด ๋ง์ ์ํ๋ฅผ ๊ฐ์ง๋ ๊ฒ์ ์ข์ ์ค๊ณ๊ฐ ์๋์ง๋ง, ์๋ฌด๊ฒ๋ ๊ฐ์ง์ง ์๋ ๋ฐฉ์ ๋ํ ๋ฐ๋์งํ ์ค๊ณ๋ ์๋๋๋ค.
์ ์ ํ ์ํ๋ฅผ ๊ฐ์ง ๊ฐ์ฒด๋ฅผ ์ค๊ณํด๋ณด๋ฉด ์ข์ ๊ฒ ๊ฐ์์.
๋ค๋ฅธ ํด๋์ค๋ค์๋ ํจ๊ป ์ ์ฉ๋๋ ํผ๋๋ฐฑ์ผ ๊ฒ ๊ฐ์ต๋๋ค :) |
@@ -0,0 +1,61 @@
+package baseball;
+
+import java.util.List;
+
+public class Referee {
+
+ public int countBall(List<Integer> list1, List<Integer> list2) {
+
+ int count = 0;
+ int strike = countStrike(list1, list2);
+
+ for (Integer number : list1) {
+ count = getCount(list2, count,... | Java | ์์์ ์ซ์๋ฅผ ์ฌ์ฉํ๋ ๋งค์ง๋๋ฒ๋์์ค ์ฝ๋๋ฅผ ์ฝ๊ธฐ ์ด๋ ต๊ฒ ๋ง๋๋๋ฐ์ !
์ด ๋ถ๋ถ์ ์ด๋ป๊ฒ ๊ฐ์ ํ ์ ์์๊น์? ๊ด๋ จ ๋งํฌ ๋จ๊ฒจ๋๊ฒ ์ต๋๋ค :)
https://www.slipp.net/questions/356 |
@@ -0,0 +1,60 @@
+package baseball;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class RefereeTest {
+
+ @Test
+ @DisplayName("๋ ๊ฐ์ ๋ฆฌ์คํธ์์ ๋ช ๊ฐ์ ์ซ์๊ฐ ๊ฐ์์ง ํ์ธ")... | Java | ํด๋น ํ
์คํธ ๋ฉ์๋์์ ์์ธ๋ฅผ ์ ์ธ์ ํ๋ ํน๋ณํ ์ด์ ๊ฐ ์๋ค๋ฉด ์ง์์ฃผ์ธ์ :)
ํ
์คํธ ๋ฉ์๋์ ์์ธ ์ ์ธ์ ํจ์ผ๋ก ์จ`ํด๋น ํ
์คํธ๊ฐ ์คํจํ ์๋ ์๋ค`๋ผ๋ ๋๋์ ์ฃผ๋ ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,61 @@
+package baseball;
+
+import java.util.List;
+
+public class Referee {
+
+ public int countBall(List<Integer> list1, List<Integer> list2) {
+
+ int count = 0;
+ int strike = countStrike(list1, list2);
+
+ for (Integer number : list1) {
+ count = getCount(list2, count,... | Java | ํต์ฌ ๋ก์ง์ ํ๋ฉด(์ฝ์ ์ถ๋ ฅ)์ ๋ํ ์๊ตฌ์ฌํญ์ด ์์ฌ์๋ค์!
๋ง์ฝ ํ๋ฉด ์๊ตฌ์ฌํญ์ด ๋ณํ๊ฒ ๋๋ค๋ฉด ์ด๋ป๊ฒ ๋ ๊น์?
ํ๋ฉด์ ์๊ตฌ์ฌํญ์ด ๋ฐ๋์์ง๋ง ๊ฐ๋ฐ์๊ฐ ์์ ํด์ผํ๋ ๋ถ๋ถ์ ๋๋ฉ์ธ์ ํต์ฌ ๋ก์ง์
๋๋ค.
์๋ ์๊ตฌ์ฌํญ์ ๋ฐ์ํด์ผํ๋ ์ด์ ์ค ํ๋๊ฐ ๋ ์ ์๊ฒ ๋ค์ :)
> ํต์ฌ ๋ก์ง์ ๊ตฌํํ๋ ์ฝ๋์ UI๋ฅผ ๋ด๋นํ๋ ๋ก์ง์ ๊ตฌ๋ถํ๋ค. |
@@ -0,0 +1,56 @@
+package baseball;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+public class ScannerUtil {
+
+ public List<Integer> makeScannerNumbers() {
+ System.out.print("์ซ์๋ฅผ ์
๋ ฅํ์ธ์: ");
+
+ ListUtil listUtil = new ListUtil();
+
+ List<Integer> integer... | Java | Scanner๋ ๋งค์ฐ ๋น์ผ ์์์
๋๋ค. ๋ฏธ๋ฆฌ ์์ฑํด๋๊ณ ์ฌํ์ฉํ๋๋ก ํด๋ณด๋ฉด ์ด๋จ๊น์ ?
static ๋ฉ์๋๋ฅผ ํ์ฉํด๋ณด๋ฉด ์ข์ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,24 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authentication.Authentication;
+import org.aopalliance.intercept.MethodInvocation;
+import org.springframework.aop.support.AopUtils;
+
+import java.lang.reflect.Method;
+
+public class SecuredAuthorizationManager implements Authoriza... | Java | Spring AOP ํ๊ฒฝ์์๋ ๋์ ๊ฐ์ฒด๊ฐ ํ๋ก์ ๊ฐ์ฒด๋ก ๊ฐ์ธ์ง ์ ์๊ธฐ ๋๋ฌธ์,
`method.getAnnotation(Secured.class)`๋ฅผ ์ฌ์ฉํ๋ฉด ์ค์ ๊ตฌํ์ฒด์ ๋ฉ์๋์์ ์ ์ธ๋ `@Secured` ์ด๋
ธํ
์ด์
์ ์ฐพ์ง ๋ชปํ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค.method.getAnnotation ์ AopUtils.getMostSpecificMethod() ์ด๋ค ์ฐจ์ด๊ฐ ์์๊น์? ๐ |
@@ -0,0 +1,11 @@
+package nextstep.security.authorization;
+
+import jakarta.servlet.http.HttpServletRequest;
+import nextstep.security.authentication.Authentication;
+
+public class AuthenticatedAuthorizationManager implements AuthorizationManager<HttpServletRequest> {
+ @Override
+ public AuthorizationDecision ... | Java | `AuthenticatedAuthorizationManager`๋ ์ธ์ฆ๋ ์ฌ์ฉ์์ ์ ๊ทผ์ ํ์ฉํ ์ง ์ฌ๋ถ๋ฅผ ๊ฒฐ์ ํ๋ ์ธ๊ฐ(Authorization) ์ญํ ์ ํ๋๋ฐ์,
๋๋ฌธ์ `request.setAttribute("username", authentication.getPrincipal());` ๋ ์ธ๊ฐ์ ์ฑ
์์ ๋ฒ์ด๋ ๋์์ผ๋ก ๋ณด์ฌ์ง๋๋ค. ๊ฐ์ ํด ๋ณด๋ฉด ์ข์ ๊ฒ ๊ฐ์์. ๐ |
@@ -1,13 +1,20 @@
package nextstep.app.ui;
+import jakarta.servlet.http.HttpServletRequest;
import nextstep.app.domain.Member;
import nextstep.app.domain.MemberRepository;
+import nextstep.app.exception.UserNotFoundException;
+import nextstep.security.authentication.Authentication;
import nextstep.security.author... | Java | `request.setAttribute`๋ฅผ ํตํด ๊ฐ์ ์ ์ฅํ๊ณ ๋ค์ ๊ฐ์ ธ์ค๋ ๊ณผ์ ์ ๊ฑฐ์น์ง ์๊ณ ,
SecurityContext์์ ์ง์ ๊ฐ์ ธ์ฌ ์ ์์ ๊ฒ ๊ฐ๋ค์ ๐ |
@@ -0,0 +1,20 @@
+package nextstep.security.authorization;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.http.HttpMethod;
+
+public class MvcRequestMatcher implements RequestMatcher {
+
+ private final HttpMethod method;
+ private final String uri;
+
+ public MvcRequestMatcher(... | Java | `matches()`๋ ์ ๊ท์ ๋งค์นญ์ ์ํํ๋ ๋ฉ์๋ ์ด๋ฏ๋ก, ๋จ์ํ ๋ฌธ์์ด ๋น๊ต์๋ ์ ํฉํ์ง ์์ ๊ฒ ๊ฐ์์.
HTTP ๋ฉ์๋(GET, POST ๋ฑ)๋ ์ ๊ท์์ด ํ์ํ์ง ์์ผ๋ฏ๋ก, `equalsIgnoreCase()`๋ฅผ ์ฌ์ฉํ๋ฉด ์ฑ๋ฅ ๋ฉด์์๋ ๋ ํจ์จ์ ์ผ ๊ฒ ๊ฐ๋ค์ ๐ |
@@ -0,0 +1,25 @@
+package nextstep.security.authorization;
+
+import jakarta.servlet.http.HttpServletRequest;
+import nextstep.security.authentication.Authentication;
+
+import java.util.List;
+
+public class RequestAuthorizationManager implements AuthorizationManager<HttpServletRequest> {
+
+ private final List<Req... | Java | `orElseGet()` ์ `orElse()`๋ ์ด๋ค ์ฐจ์ด๊ฐ ์์๊น์? ๐ |
@@ -11,29 +11,29 @@
import org.springframework.aop.framework.AopInfrastructureBean;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
-import java.lang.reflect.Method;
-
public class SecuredMethodInterceptor implements MethodInterceptor, PointcutAdvisor, AopInfrastructureBean {
p... | Java | `@Secured` ์ด๋
ธํ
์ด์
์ด ์กด์ฌํ๋์ง ๋ค์ ๊ฒ์ฌํ๊ณ ์๋๋ฐ์,
์ด๋ฏธ `AnnotationMatchingPointcut`์ ํตํด `@Secured`์ด ๋ถ์ ๋ฉ์๋๋ง ์ธํฐ์
ํธํ๋๋ก ์ค์ ๋์ด ์๊ธฐ ๋๋ฌธ์,
`if (!method.isAnnotationPresent(Secured.class))` ๋ถ๋ถ์ ์ ๊ฑฐํด๋ ๋ ๊ฒ ๊ฐ์์. ๐ |
@@ -17,6 +17,7 @@
import java.util.Set;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTe... | Java | ํ
์คํธ ์ค๋ช
์ด ์๋ชป๋์ด ์๋ค์ ๐ |
@@ -11,29 +11,29 @@
import org.springframework.aop.framework.AopInfrastructureBean;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
-import java.lang.reflect.Method;
-
public class SecuredMethodInterceptor implements MethodInterceptor, PointcutAdvisor, AopInfrastructureBean {
p... | Java | > ๊ณ ๋ฏผํ ๋ถ๋ถ
> Q. securedAuthorizationManager ๋ก์ง์ด ์ํ๋๋ ์์ ์ด SecuredMethodInterceptor ์์์ ์ํ๋๋ ๊ฒ์ด ๋ง๋์ง ๊ถ๊ธํฉ๋๋ค.
A. AOP๋ฅผ ํตํด ๋ฉ์๋๊ฐ ์คํ๋๊ธฐ ์ ์ ์ธ๊ฐ(Authorization) ๋ก์ง์ ์ํํ๋๋ก ์ ๊ตฌํํด ์ฃผ์
จ๋ค์! ๐
ํน์ ๊ณ ๋ฏผํ๋ ๋ถ๋ถ์ด ์์ผ์
จ๋ค๋ฉด ๋จ๊ฒจ์ฃผ์๋ฉด ์ ๋ ๊ณ ๋ฏผํด๋ณด๊ณ ๋ต๋ณ ๋๋ฆฌ๋๋ก ํ๊ฒ ์ต๋๋ค ๐ |
@@ -0,0 +1,24 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authentication.Authentication;
+import org.aopalliance.intercept.MethodInvocation;
+import org.springframework.aop.support.AopUtils;
+
+import java.lang.reflect.Method;
+
+public class SecuredAuthorizationManager implements Authoriza... | Java | AopUtils.getMostSpecificMethod() ๋ก ์ค์ ๋ฉ์๋์ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์ฌ ์ ์๊ฒ ๋ค์!
๊ทธ๋๋ ์ด๋
ธํ
์ด์
์ ๋ณด๋ฅผ ๊ฐ์ ธ์ค๋ ค๋ฉด getAnnotation ๋ฉ์๋๋ ๊ณ์ ์ฌ์ฉํด์ผ ํ๋ ๊ฑฐ์ฃ ?
์์ ํด๋ดค๋๋ฐ ๋ง๋ ๋ฐฉ์์ธ์ง ํ์ธ ๋ถํ๋๋ฆฝ๋๋ค! |
@@ -0,0 +1,20 @@
+package nextstep.security.authorization;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.http.HttpMethod;
+
+public class MvcRequestMatcher implements RequestMatcher {
+
+ private final HttpMethod method;
+ private final String uri;
+
+ public MvcRequestMatcher(... | Java | ์ ๊ฐ ์ matches๋ฅผ ์ฌ์ฉํ๋์ง ๋ชจ๋ฅด๊ฒ ๋ค์.. ๊ผผ๊ผผํ ๋ฆฌ๋ทฐ ๊ฐ์ฌํฉ๋๋ค ๐ |
@@ -11,29 +11,29 @@
import org.springframework.aop.framework.AopInfrastructureBean;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
-import java.lang.reflect.Method;
-
public class SecuredMethodInterceptor implements MethodInterceptor, PointcutAdvisor, AopInfrastructureBean {
p... | Java | ๋ค๋ฅธ AuthorizationManager ๋ค์ Filter์์ ์ธ๊ฐ ๋ก์ง์ด ์ํ๋๋๋ฐ ์ด์ ๋ค๋ฅด๊ฒ AOP๋ฅผ ํตํด ์ํ๋๋ ๋ก์ง์ด์ด์ ๋ง๋ ๋ฐฉ์์ธ์ง ๊ถ๊ธํ์์ต๋๋ค..! ๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค ๐ |
@@ -0,0 +1,25 @@
+package nextstep.security.authorization;
+
+import jakarta.servlet.http.HttpServletRequest;
+import nextstep.security.authentication.Authentication;
+
+import java.util.List;
+
+public class RequestAuthorizationManager implements AuthorizationManager<HttpServletRequest> {
+
+ private final List<Req... | Java | orElse๋ก ๊ตฌํํ๊ฒ ๋๋ฉด, null์ด ์๋์ด๋ AuthorizationDecision ๊ฐ์ฒด ์์ฑ ๋ก์ง์ ์ํ๋ ๊ฒ ๊ฐ๋ค์.
orElseGet์ผ๋ก ์์ ํ์ต๋๋ค! |
@@ -0,0 +1,24 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authentication.Authentication;
+import org.aopalliance.intercept.MethodInvocation;
+import org.springframework.aop.support.AopUtils;
+
+import java.lang.reflect.Method;
+
+public class SecuredAuthorizationManager implements Authoriza... | Java | method.getClass()๋ Method ํด๋์ค ์์ฒด์ ํ์
์ ๋ฐํํ๋ฏ๋ก, ์ฌ๋ฐ๋ฅธ ๋์ ํด๋์ค(Target Class)๋ฅผ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
invocation.getThis()๋ฅผ ์ฌ์ฉํ์ฌ ์ค์ ๋์ ๊ฐ์ฒด(Target Object)์ ํด๋์ค๋ฅผ ๊ฐ์ ธ์ค๋ ๊ฒ์ด ์ข๊ฒ ๋ค์ ๐
`Class<?> targetClass = AopUtils.getTargetClass(invocation.getThis());` |
@@ -0,0 +1,24 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authentication.Authentication;
+import org.aopalliance.intercept.MethodInvocation;
+import org.springframework.aop.support.AopUtils;
+
+import java.lang.reflect.Method;
+
+public class SecuredAuthorizationManager implements Authoriza... | Java | ๋ค ๋ง์ต๋๋ค
์ด๋
ธํ
์ด์
์ ๋ณด๋ฅผ ๊ฐ์ ธ์ค๋ ๊ฒ์ ๋์ผํ๊ฒ getAnnotation(Secured.class)์ ์ฌ์ฉํด์ผ ํฉ๋๋ค. ๐ |
@@ -11,29 +11,29 @@
import org.springframework.aop.framework.AopInfrastructureBean;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
-import java.lang.reflect.Method;
-
public class SecuredMethodInterceptor implements MethodInterceptor, PointcutAdvisor, AopInfrastructureBean {
p... | Java | Filter ๊ธฐ๋ฐ ์ธ๊ฐ๋ HTTP ์์ฒญ ๋จ์์์ ์ ์ฉ๋์ง๋ง,
`@Secured`๋ ๊ฐ๋ณ ๋ฉ์๋ ํธ์ถ ๋จ์์์ ๋ณด์ ๊ฒ์ฌ๋ฅผ ํด์ผ ํด์ ์ ์ ํ ๊ตฌํ ๋ฐฉ์์
๋๋ค ๐ |
@@ -0,0 +1,136 @@
+import Event from "../src/domain/Event.js";
+
+describe('์ด๋ฒคํธ ๊ด๋ฆฌ์ Event ํด๋์ค ํ
์คํธ', () => {
+ test.each([['0'], ['-25'], ['1.1'], ['32']])('1๋ถํฐ 31 ์ฌ์ด์ ์์ฐ์๊ฐ ์๋์ ์์ธ์ฒ๋ฆฌ', (input) => {
+ expect(() => {
+ const event = new Event(input);
+ event.date()
+ }).toThrow('[ERROR]');
+ });
+
+ test... | JavaScript | ๊ฐ ํ
์คํธ์ ๋ํด ๋จ์ผ ๊ฐ์ ์ฃผ๋ ๊ฒฝ์ฐ์ ๋ํด์๋ []๋ฅผ ํฌํจํ์ง ์์๋ ๋๋ ๊ฑธ๋ก ์๊ณ ์์ด์!! ํ ๋ฒ ํ์ธํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์์ |
@@ -0,0 +1,110 @@
+import {
+ priceFilter,
+ PRICE_REFINER,
+ merageFoodInfo,
+ BENEFITS_REFINER,
+ isNotApplicableBenefits
+} from "../src/constants/ViewRefiner.js";
+
+test('์ซ์๋ฅผ ์ฒ๋จ์๋ก ์๋ผ์ ๋ฌธ์๋ก ๋ณํ๋๋์ง ํ
์คํธ', () => {
+ const NUMBER = 1234567890;
+ const PRICE_STRING = '1,234,567,890';
+
+ expect(priceFilter(NUMBE... | JavaScript | ๋๋ฉ์ธ ๋ก์ง์ด๋ ํ์ค ๋ฌธ์ ์ ๋ํ ์์ฌ๊ฒฐ์ ์ ํ๋ ์ฝ๋๋ก ์๊ณ ์๋๋ฐ, ํน์ ํด๋น ํ
์คํธ๊ฐ ๋๋ฉ์ธ ๋ก์ง์ ๋ํ ํ
์คํธ์ธ์ง ์ฌ์ญ๊ณ ์ถ์ต๋๋น! |
@@ -1,7 +1,67 @@
-export default OutputView = {
- printMenu() {
- Console.print("<์ฃผ๋ฌธ ๋ฉ๋ด>");
- // ...
- }
- // ...
-}
+import { Console } from "@woowacourse/mission-utils";
+import { ANSWER } from "./constants/PlannerMesseage.js";
+import { PRICE_REFINER, BENEFITS_REFINER } from "./constants/ViewR... | JavaScript | **OutputView**๊ฐ ์ ๋ง ๊น๋ํ๊ฒ ์ ์ ๋ฆฌ๋์ด ์๋ ๊ฒ ๊ฐ์ต๋๋ค ! ๐๐ |
@@ -0,0 +1,81 @@
+import Supervisor from "../domain/Supervisor.js";
+import InputView from "../InputView.js";
+import OutputView from "../OutputView.js";
+
+class EventPlanner {
+ #supervisor;
+
+ constructor() {
+ this.#supervisor = new Supervisor();
+ }
+
+ async start() {
+ OutputView.printIntroduce();
+... | JavaScript | `getDate`์ `getMenu` ๋ฉ์๋์์ ์ฌ์
๋ ฅ ์์ฒญ์ ๋ํ `try catch` ๊ตฌ๋ฌธ์ด ์ค๋ณต๋์ด์ ์ฌ์ฉ๋๋ ๊ฒ ๊ฐ์์! ์ฌ์
๋ ฅ ์์ฒญ์ ๋ํ `try catch` ๊ตฌ๋ฌธ์ ํจ์๋ก ๋ถ๋ฆฌํ๋ ๋ฐฉ๋ฒ์ ๋ํด ๊ณ ๋ คํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,84 @@
+import { dateValidator } from "../util/Validator.js";
+import {
+ DISCOUNT,
+ BADGE,
+ BENEFIT_MESSEAGE
+} from "../constants/BenefitStorage.js";
+
+class Event {
+ #date;
+
+ constructor(date) {
+ dateValidator(date);
+ this.#date = Number(date);
+ }
+
+ #week() {
+ const WEEK = ... | JavaScript | ์์ผ์ ๋ํ ๊ฐ๋ค์ ์์๋ก ์ ์ธํ๊ณ , ์์๋ฅผ ํ์ฉํ๋ฉด ๊ฐ๋
์ฑ ํฅ์์ ๋์๋ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,49 @@
+import { foodValidator } from "../util/Validator.js";
+import {
+ MENU,
+ NAME,
+ KNIFE
+} from "../constants/FoodStorage.js";
+
+class Food {
+ #name;
+
+ #quantity;
+
+ constructor(food) {
+ foodValidator(this.#enrollFood(food));
+ }
+
+ #enrollFood(food) {
+ const foodInfoArray = ... | JavaScript | ํ์
, ์ด๋ฆ, ํํฐํฐ ๋ฑ๋ฑ ๋ฐํํด์ฃผ๋ ํจ์๋ช
์ ๋ํด `get`์ ๋ถ์ฌ์ฃผ๋๊ฒ ๊ฐ๋
์ฑ ํฅ์์ ๋ ๋์์ด ๋์ง ์์๊น์?? |
@@ -0,0 +1,46 @@
+import { ERROR_DATE, ERROR_MENU } from "../constants/ErrorMesseage.js";
+import { MENU, KNIFE } from "../constants/FoodStorage.js";
+
+export const dateValidator = (date) => {
+ if (
+ date.includes(' ') ||
+ date.includes('.') ||
+ Number.isNaN(Number(date)) ||
+ !Number.isInteger(Number... | JavaScript | `if` ๋ฌธ ๋ด๋ถ์์ ๊ฒ์ฆํ๋ ๊ฒ๋ค์ด ๋๋ฌด ๋ง์์ ์คํ๋ ค ๊ฐ๋
์ฑ์ด ๋จ์ด์ ธ ๋ณด์ผ ์๋ ์์ ๊ฒ ๊ฐ์์,,!
์ด ๋ถ๋ถ์ ์ ๊ทํํ์์ ํ์ฉํ๋ค๋ฉด ๊ฐ๋
์ฑ ํฅ์์ ๋์์ด ๋ ์ ์์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,110 @@
+import {
+ priceFilter,
+ PRICE_REFINER,
+ merageFoodInfo,
+ BENEFITS_REFINER,
+ isNotApplicableBenefits
+} from "../src/constants/ViewRefiner.js";
+
+test('์ซ์๋ฅผ ์ฒ๋จ์๋ก ์๋ผ์ ๋ฌธ์๋ก ๋ณํ๋๋์ง ํ
์คํธ', () => {
+ const NUMBER = 1234567890;
+ const PRICE_STRING = '1,234,567,890';
+
+ expect(priceFilter(NUMBE... | JavaScript | ํํ ๋ด์ญ์ map์์ ๊ด๋ฆฌ ํ๋ค๋ณด๋ ์ถ๋ ฅ ํํ๋ก ๋ณํํ๋ ๋ก์ง์ด ๋ค์ ๋ณต์กํด์ก์ต๋๋ค. ํด๋น ๋ก์ง์ ๊ทธ ์ญํ ์ ํด์ฃผ๋๋ฐ ์๊ฐ๋ณด๋ค ๋ณต์กํ๊ณ ์ค์๋ฅผ ๋ง์ด ํ ๋ถ๋ถ์ด๋ผ ํ
์คํธ๋ฅผ ์งํํ์ต๋๋ค! |
@@ -0,0 +1,81 @@
+import Supervisor from "../domain/Supervisor.js";
+import InputView from "../InputView.js";
+import OutputView from "../OutputView.js";
+
+class EventPlanner {
+ #supervisor;
+
+ constructor() {
+ this.#supervisor = new Supervisor();
+ }
+
+ async start() {
+ OutputView.printIntroduce();
+... | JavaScript | ๋ฆฌํฉํ ๋ง๋ ์ ์ฉํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค! ๐ |
@@ -0,0 +1,84 @@
+import { dateValidator } from "../util/Validator.js";
+import {
+ DISCOUNT,
+ BADGE,
+ BENEFIT_MESSEAGE
+} from "../constants/BenefitStorage.js";
+
+class Event {
+ #date;
+
+ constructor(date) {
+ dateValidator(date);
+ this.#date = Number(date);
+ }
+
+ #week() {
+ const WEEK = ... | JavaScript | ์์ ์ฒ๋ฆฌ๋ ํ์์ง๋ง ์ง๊ธ ๋ค์ ๋ด๋ ํด๋์ค ๋ด์์ ์ ์ธํ ๋ถ๋ถ์ ๋ง์๋๋ก ๋ง์ด ์์ฌ์ด ๊ฒ ๊ฐ์ต๋๋คใ
์์ผ์ ์ด๋ฆ์ ํ๋ค์์ ํ ์ง๋ ๊ณ ๋ฏผ์ด์๋๋ฐ ๋ ๊ธ์๋ก๋ ์ถฉ๋ถํ ๊ฒ ๊ฐ์ ์ฝ์ด๋ฅผ ์ฌ์ฉํ์์ต๋๋ค. |
@@ -0,0 +1,49 @@
+import { foodValidator } from "../util/Validator.js";
+import {
+ MENU,
+ NAME,
+ KNIFE
+} from "../constants/FoodStorage.js";
+
+class Food {
+ #name;
+
+ #quantity;
+
+ constructor(food) {
+ foodValidator(this.#enrollFood(food));
+ }
+
+ #enrollFood(food) {
+ const foodInfoArray = ... | JavaScript | get์ ์ ํํ ์ธ์ ๋ถ์ฌ์ผ ํ ์ง ๊ณ ๋ฏผ์ด ๋ฉ๋๋ค. type ๋ฉ์๋์ ๊ฒฝ์ฐ type์ ๊ฐ์ ธ์ค๋ ๊ฒ์ด๋ get์ ๋ถ์ฌ์ผ ํ ์ง,
๋จ์ํ ํ๋ ๊ฐ์ ๊ฐ์ ธ์ค๋๊ฒ ์๋๋ผ ์์ฐํ ๋ก์ง์ด ๊ตฌํ ๋์ด ์์ผ๋ food.type() ์ฐ๋ก๋ ์๋ฏธ ์ ๋ฌํ ์ถฉ๋ถํ์ง ์์ง ํ๊ฐ๋ฆฌ๋ ๋ถ๋ถ์ธ ๊ฒ ๊ฐ์ต๋๋ค.ใ
ใ
|
@@ -0,0 +1,106 @@
+import Cashier from "../src/domain/Cashier.js";
+
+describe('Cashier ํด๋์ค ์ ํจ์ฑ ํ
์คํธ', () => {
+ test.each([
+ ['์ ๋ก์ฝ๋ผ-10'],
+ ['์ ๋ก์ฝ๋ผ-2,์ดํ์ธ-4'],
+ ['์ดํ์ธ-3,๋ ๋์์ธ-1,์ ๋ก์ฝ๋ผ-2']
+ ])('์๋ฃ๋ง ์ฃผ๋ฌธ์ ์์ธ์ฒ๋ฆฌ', (input) => {
+ expect(() => new Cashier(input)).toThrow('[ERROR');
+ });
+
+ test.each([
+ ['์์ด... | JavaScript | ํ
์คํธ ๊ผผ๊ผผํ๊ฑฐ ๋๋ฌด ์ข์ต๋๋ค! ๐ ๊ทธ๋ฐ๋ฐ ํ
์คํธ๋ฌธ๊ตฌ ์์์ ํ๋๋ก ํต์ผํ๋ฉด ์ข์ ๊ฒ ๊ฐ์์!
ํด๋น ๋ฌธ๊ตฌ์ฒ๋ผ `์์ธ๋ฅผ ๋ฐ์์ํค์ง ์๋๋ค`. ์ ๋ง์ถฐ์ `์์ธ์ฒ๋ฆฌ` -> `์์ธ๋ฅผ ๋ฐ์์ํจ๋ค` ๋ก ํต์ผํ๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,70 @@
+import Food from "./Food.js";
+import { ERROR_MENU } from "../constants/ErrorMesseage.js";
+import { merageFoodInfo } from "../constants/ViewRefiner.js";
+import { DISCOUNT, BENEFIT_MESSEAGE } from "../constants/BenefitStorage.js";
+import { NAME } from "../constants/FoodStorage.js";
+
+class Cashier ... | JavaScript | ํน์ ์ถ๋ ฅ๊ณผ ๊ด๋ จ๋ ํฌ๋งทํ
๋ถ๋ถ์ ๋๋ฉ์ธ์์ ์ฒ๋ฆฌํ ์ด์ ๊ฐ ์์ผ์ค๊น์? ๊ถ๊ธํฉ๋๋ค! ํฌ๋งทํ
ํด์ฃผ๋ ๊ฒ๋ ๋๋ฉ์ธ์ ์ญํ ์ด๋ผ๊ณ ์๊ฐํ์
จ๊ธฐ ๋๋ฌธ์ผ๊น์? |
@@ -1,7 +1,67 @@
-export default OutputView = {
- printMenu() {
- Console.print("<์ฃผ๋ฌธ ๋ฉ๋ด>");
- // ...
- }
- // ...
-}
+import { Console } from "@woowacourse/mission-utils";
+import { ANSWER } from "./constants/PlannerMesseage.js";
+import { PRICE_REFINER, BENEFITS_REFINER } from "./constants/ViewR... | JavaScript | ํด๋น๋ถ๋ถ messeage ๊ทธ๋ฅ ๋ฐ๋ก ์ถ๋ ฅํด๋ ๋ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -1,7 +1,67 @@
-export default OutputView = {
- printMenu() {
- Console.print("<์ฃผ๋ฌธ ๋ฉ๋ด>");
- // ...
- }
- // ...
-}
+import { Console } from "@woowacourse/mission-utils";
+import { ANSWER } from "./constants/PlannerMesseage.js";
+import { PRICE_REFINER, BENEFITS_REFINER } from "./constants/ViewR... | JavaScript | ์ ๋ชฉ ๋ถ๋ถ์ด๋ผ์ ๋ค ๋์ด์ฐ๊ธฐ๋ฅผ ํ์ ๊ฑธ๊น์? ๊ผผ๊ผผํฉ๋๋ค! ๐ |
@@ -0,0 +1,40 @@
+export const DISCOUNT = Object.freeze({
+ christmasDate : 25,
+ christmasBasic : 1000,
+ christmasAccumulation : 100,
+ weekday : 2023,
+ weekend : 2023,
+ special : 1000,
+ freebieItem : '์ดํ์ธ 1๊ฐ',
+ freebieStandard : 120000,
+ freebiePrice : 25000,
+ eventStandardAmount : 10000,
+ zero : 0... | JavaScript | ํด๋น ์ดํ์ธ์ string์ผ๋ก ๋ฃ๊ธฐ๋ณด๋ค ์ ์ธํด๋์ผ์ ์์ ์จ๋ ์ข์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,40 @@
+export const DISCOUNT = Object.freeze({
+ christmasDate : 25,
+ christmasBasic : 1000,
+ christmasAccumulation : 100,
+ weekday : 2023,
+ weekend : 2023,
+ special : 1000,
+ freebieItem : '์ดํ์ธ 1๊ฐ',
+ freebieStandard : 120000,
+ freebiePrice : 25000,
+ eventStandardAmount : 10000,
+ zero : 0... | JavaScript | ๋ณ์๋ช
์ ๊ฐ๊ฒฉ์ด๋ผ๋๊ฒ ๋ ๋๋ฌ๋๋ฉด ์ข์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,40 @@
+export const DISCOUNT = Object.freeze({
+ christmasDate : 25,
+ christmasBasic : 1000,
+ christmasAccumulation : 100,
+ weekday : 2023,
+ weekend : 2023,
+ special : 1000,
+ freebieItem : '์ดํ์ธ 1๊ฐ',
+ freebieStandard : 120000,
+ freebiePrice : 25000,
+ eventStandardAmount : 10000,
+ zero : 0... | JavaScript | ๊ผผ๊ผผํ์ญ๋๋น!! ๐๐๐ |
@@ -0,0 +1,40 @@
+export const DISCOUNT = Object.freeze({
+ christmasDate : 25,
+ christmasBasic : 1000,
+ christmasAccumulation : 100,
+ weekday : 2023,
+ weekend : 2023,
+ special : 1000,
+ freebieItem : '์ดํ์ธ 1๊ฐ',
+ freebieStandard : 120000,
+ freebiePrice : 25000,
+ eventStandardAmount : 10000,
+ zero : 0... | JavaScript | ๊ทธ๋ฆฌ๊ณ ํด๋น `DISCOUNT` ์์์ ์ด๋ฒคํธ์ ๊ด๋ จ๋ ๋ชจ๋ ์ ๋ณด๊ฐ ๋ค์ด๊ฐ์๋๋ฐ, ์์ ํฌ๋ฆฌ์ค๋ง์ค ์ด๋ฒคํธ, ํ์ผ ์ด๋ฒคํธ, ๋ฑ๋ฑ์ผ๋ก ์์๋ฅผ ์ชผ๊ฐ๊ฑฐ๋, ํน์ ์ค๊ฐ์ ๊ณต๋ฐฑ๋ผ์ธ์ ๋ฃ์ผ๋ฉด ์ข์ ๊ฒ ๊ฐ์์! ๊ตฌ๋ถ๋์ด์์ง ์๋ค๋ณด๋๊น ํ์
ํ๊ธฐ ์กฐ๊ธ ์ด๋ ค์ธ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,40 @@
+export const DISCOUNT = Object.freeze({
+ christmasDate : 25,
+ christmasBasic : 1000,
+ christmasAccumulation : 100,
+ weekday : 2023,
+ weekend : 2023,
+ special : 1000,
+ freebieItem : '์ดํ์ธ 1๊ฐ',
+ freebieStandard : 120000,
+ freebiePrice : 25000,
+ eventStandardAmount : 10000,
+ zero : 0... | JavaScript | `star : { price : 5000, name : '๋ณ'}` ํด๋น ํ์์ ์ด๋จ์ง ์ถ์ฒํ๊ณ ๊ฐ๋๋ค! |
@@ -0,0 +1,14 @@
+export const ERROR_DATE = Object.freeze({
+ basic : '[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.',
+ minDate : 1,
+ maxDate : 31,
+});
+
+export const ERROR_MENU = Object.freeze({
+ basic : '[ERROR] ์ ํจํ์ง ์์ ์ฃผ๋ฌธ์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.',
+ onlyDrink : '[ERROR] ์๋ฃ๋ง ์ฃผ๋ฌธ ์, ์ฃผ๋ฌธํ ์ ์์ต๋๋ค.',
+ maxOrder : '[ERROR] ๋ฉ๋ด๋ ํ ๋ฒ์... | JavaScript | ํด๋น 20๋ ์์๋ก ๋นผ๋ฉด ์ข์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,43 @@
+export const APPETIZER = Object.freeze({
+ '์์ก์ด์ํ' : 6000,
+ 'ํํ์ค' : 5500,
+ '์์ ์๋ฌ๋' : 8000,
+ 'type' : 'appetizer',
+});
+
+export const MAIN = Object.freeze({
+ 'ํฐ๋ณธ์คํ
์ดํฌ' : 55000,
+ '๋ฐ๋นํ๋ฆฝ' : 54000,
+ 'ํด์ฐ๋ฌผํ์คํ' : 35000,
+ 'ํฌ๋ฆฌ์ค๋ง์คํ์คํ' : 25000,
+ 'type' : 'main',
+});
+
+export const DESERT = Obj... | JavaScript | ํ์
๋ถ๋ถ์ ํด๋น ๊ฐ์ฒด์ ๋ง์ง๋ง์ ๋ฃ๊ธฐ๋ณด๋จ, ๋ฐ๋ก ๋นผ์ ํ์ธํ๋๊ฒ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค!
๊ฐ์ฒด๊ฐ ์ค๊ฐ์ ์์ฑ์ด ๋ค๋ฅผ ๊ฒฝ์ฐ, ์ ์ง๋ณด์๋ ํ๋ค๋ฟ๋ง ์๋๋ผ ๋งค๋ฒ `APPETIZER`์ ๋ง์ง๋ง ์์ฑ์ type์ด๋ผ๋๊ฑธ ๊ธฐ์ตํด๋๊ณ ์ฝ๋๋ฅผ ์ง์ผํด์, type์ ํด๋น ๊ฐ์ฒด์์ ๋ฐ๋ก ๋นผ๋๊ฒ ์ข์๋ณด์
๋๋ค!
```js
export const APPETIZER = Object.freeze({
'์์ก์ด์ํ': 6000,
'ํํ์ค': 5500,
'์์ ์๋ฌ๋': 8000,
});
``` |
@@ -0,0 +1,43 @@
+export const APPETIZER = Object.freeze({
+ '์์ก์ด์ํ' : 6000,
+ 'ํํ์ค' : 5500,
+ '์์ ์๋ฌ๋' : 8000,
+ 'type' : 'appetizer',
+});
+
+export const MAIN = Object.freeze({
+ 'ํฐ๋ณธ์คํ
์ดํฌ' : 55000,
+ '๋ฐ๋นํ๋ฆฝ' : 54000,
+ 'ํด์ฐ๋ฌผํ์คํ' : 35000,
+ 'ํฌ๋ฆฌ์ค๋ง์คํ์คํ' : 25000,
+ 'type' : 'main',
+});
+
+export const DESERT = Obj... | JavaScript | ์ด ๋ถ๋ถ์ `-` ๋ก ์ชผ๊ฐฐ์๋ ๋์ค๋ ๋ฐฐ์ด์ index๋ฅผ ๊ฐ์ ธ์ค๊ธฐ ์ํ ์์ ๋ง์๊น์? ๊ทธ๋ ๋ค๋ฉด ๊ตฌ์กฐ๋ถํดํ ๋น ์ฐ๋ฉด ๋ ๊น๋ํ ๊ฒ ๊ฐ์์! ๊ทธ๋ ๊ฒ ๋๋ค๋ฉด `KNIFE `์์๋ช
๋ณด๋ค๋ `delimiter`๋ `seperator`๋ก ๋ฐ๊พธ๋๊ฒ๋ ์ข์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,14 @@
+export const ERROR_DATE = Object.freeze({
+ basic : '[ERROR] ์ ํจํ์ง ์์ ๋ ์ง์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.',
+ minDate : 1,
+ maxDate : 31,
+});
+
+export const ERROR_MENU = Object.freeze({
+ basic : '[ERROR] ์ ํจํ์ง ์์ ์ฃผ๋ฌธ์
๋๋ค. ๋ค์ ์
๋ ฅํด ์ฃผ์ธ์.',
+ onlyDrink : '[ERROR] ์๋ฃ๋ง ์ฃผ๋ฌธ ์, ์ฃผ๋ฌธํ ์ ์์ต๋๋ค.',
+ maxOrder : '[ERROR] ๋ฉ๋ด๋ ํ ๋ฒ์... | JavaScript | `ERROR_MENU`์๋ ์๋ฌ์ ๊ด๋ จ๋๊ฒ๋ง ์์ผ๋ฉด ์ข์ ๊ฒ ๊ฐ์๋ฐ, 11,12,13 line์ ์กฐ๊ธ ์ ๋งคํ ๊ฒ ๊ฐ์ต๋๋ค!
`ERROR_MENU`-> `MENU`๋ก ๋ฐ๊พธ๊ณ , ๊ทธ ์์ `ERROR`๋ก ํ๋ฒ ๋ ๊ฐ์ธ๋๊ฑด ์ด๋จ์ง ์ถ์ฒํ๊ณ ๊ฐ๋๋น! |
@@ -0,0 +1,41 @@
+import { BENEFIT_MESSEAGE } from "./BenefitStorage.js";
+import { EVENT_NAME } from "./BenefitStorage.js";
+
+export const priceFilter = (priceNumber) => new Intl.NumberFormat('ko-KR').format(priceNumber);
+
+export const merageFoodInfo = (foodName, foodAmount) => `${foodName} ${foodAmount}๊ฐ`;
+
+expo... | JavaScript | ํด๋น ๊ฐ์ฒด์ ๊ฒฝ์ฐ positive, negative์์ฑ์ ๋๋์ง๋ง๊ณ ์ฒ์๋ถํฐ 3๊ฐ์ง ์กฐ๊ฑด๋ฌธ์ผ๋ก ๋ฐ๋ก ๊ฒ์ฌํ๋ฉด ์ด๋จ๊น์? |
@@ -0,0 +1,41 @@
+import { BENEFIT_MESSEAGE } from "./BenefitStorage.js";
+import { EVENT_NAME } from "./BenefitStorage.js";
+
+export const priceFilter = (priceNumber) => new Intl.NumberFormat('ko-KR').format(priceNumber);
+
+export const merageFoodInfo = (foodName, foodAmount) => `${foodName} ${foodAmount}๊ฐ`;
+
+expo... | JavaScript | ํน์ ์๋ค๋ ์์๋ผ๊ณ ๋ณผ ์ ์๋๋ฐ ์นด๋ฉ์ผ์ด์ค๋ก ์์ฑํ์ ์ด์ ๊ฐ ์์๊น์? |
@@ -0,0 +1,41 @@
+import { BENEFIT_MESSEAGE } from "./BenefitStorage.js";
+import { EVENT_NAME } from "./BenefitStorage.js";
+
+export const priceFilter = (priceNumber) => new Intl.NumberFormat('ko-KR').format(priceNumber);
+
+export const merageFoodInfo = (foodName, foodAmount) => `${foodName} ${foodAmount}๊ฐ`;
+
+expo... | JavaScript | ์ฌ๊ธฐ !==๋ค์ ๋์ด์ฐ๊ธฐ 1๋ฒ ํด์ผํ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,81 @@
+import Supervisor from "../domain/Supervisor.js";
+import InputView from "../InputView.js";
+import OutputView from "../OutputView.js";
+
+class EventPlanner {
+ #supervisor;
+
+ constructor() {
+ this.#supervisor = new Supervisor();
+ }
+
+ async start() {
+ OutputView.printIntroduce();
+... | JavaScript | ํด๋น ๋ถ๋ถ์ ๋ฐ๋ก ํจ์๋ก ์๋นผ๊ณ `OutputView.print~`๋ก ๋ฐ๋ก ๋ฃ์ด๋ ๊ด์ฐฎ์ง ์์๊น ํฉ๋๋ค!
๊ฐ๊ฐ์ ํจ์์์ ๋ฐ๋ก ์ถ๊ฐ์ ์ธ ๊ธฐ๋ฅ์ด ์๋๊ฒ ์๋๋ผ์, OutputView๋ก ๋ฐ๋ก ๋ค์ด๊ฐ๋ ์ข์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,70 @@
+import Food from "./Food.js";
+import { ERROR_MENU } from "../constants/ErrorMesseage.js";
+import { merageFoodInfo } from "../constants/ViewRefiner.js";
+import { DISCOUNT, BENEFIT_MESSEAGE } from "../constants/BenefitStorage.js";
+import { NAME } from "../constants/FoodStorage.js";
+
+class Cashier ... | JavaScript | import ์์๋ ๋ง์ถฐ์ฃผ๋ฉด ์ข์ ๊ฒ ๊ฐ์์! ์๋ฅผ ๋ค์ด constants๋ถ๋ถ๋ ์ํ๋ฒณ ์์ผ๋ก importํด์ค๋ค๊ฑฐ๋,,! |
@@ -0,0 +1,70 @@
+import Food from "./Food.js";
+import { ERROR_MENU } from "../constants/ErrorMesseage.js";
+import { merageFoodInfo } from "../constants/ViewRefiner.js";
+import { DISCOUNT, BENEFIT_MESSEAGE } from "../constants/BenefitStorage.js";
+import { NAME } from "../constants/FoodStorage.js";
+
+class Cashier ... | JavaScript | ํด๋น ๋ถ๋ถ๋ split๋ถ๋ถ์ด๋๊น ๋ฐ๋ก ์์๋ก ๋ง๋ค์ด์ค๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,35 @@
+package nextstep.subway.applicaion;
+
+import java.util.List;
+import nextstep.subway.applicaion.dto.PathResponse;
+import nextstep.subway.domain.Line;
+import nextstep.subway.domain.LineRepository;
+import nextstep.subway.domain.Path;
+import nextstep.subway.domain.PathFinder;
+import nextstep.subway... | Java | ๊ฒฝ๋ก๋ฅผ ์ฐพ๊ธฐ์ํด lines๋ผ๋ ์ ๋ณด๊ฐ ์๊ณ , ์ด ์ ๋ณด๋ฅผ ์ด์ฉํด ๊ฒฝ๋ก๋ฅผ ์ฐพ๋๋ฐ ์ด ๊ฒฝ๋ก๋ฅผ ์ฐพ๋ ์ฑ
์์ PathFinder๊ฐ ๊ฐ์ง๊ณ ์๊ณ ๊ทธ ๊ฒฐ๊ณผ ์ ๋ณด๋ Path๊ฐ ๊ฐ์ง๊ณ ์๋ค์!
๊ฐ์ฒด์งํฅ์์ ๊ฐ์ฒด๋ ์ํ์ ํ์๋ก ์ด๋ฃจ์ด์ ธ์๋ค๊ณ ํ๋๋ฐ์
๊ฒฝ๋ก๋ฅผ ์ฐพ๊ธฐ ์ํ ์ํ์ธ lines์ ํ์์ธ PathFinder๋ฅผ ํ๋์ ๊ฐ์ฒด๋ก ๋์ถํด๋ณผ ์๋ ์์๊น์?
๋ง์ฝ์ ์ด๋ ๊ฒ ๋ฆฌํฉํฐ๋ง ํ ๊ฒฝ์ฐ ๊ธฐ์กด์ ๋ง๋ค์ด ๋์๋ ํ
์คํธ๋ฅผ ํ์ฉํด์ ํ
์คํธ์ ๊ฒ์ฆ์ด๋ผ๋ ๋ณดํธ ์์ ๋ฆฌํฉํฐ๋ง์ ํด๋ณด์๋ ๊ฒ์ ๊ถํด๋๋ฆฝ๋๋ค! |
@@ -63,19 +63,19 @@ public void update(Station newUpStation, int minusDistance) {
}
public Section merge(Section section) {
- if (!isDownStation(section.upStation)) {
+ if (!hasDownStationAs(section.upStation)) {
throw new IllegalArgumentException("ํฉ์น๋ ค๋ ๊ตฌ๊ฐ์ ์ํ์ญ์ด ํํ์ญ๊ณผ ๊ฐ์์ผ ํฉ๋๋ค.");
... | Java | ๋ณ๊ฒฝ๋ ๋ค์ด๋ฐ์ด ์๋ฏธ๋ฅผ ์กฐ๊ธ ๋ ์ ์ ๋ฌํ๋ ๊ฒ ๊ฐ์์ ๐ |
@@ -1,6 +1,7 @@
package nextstep.subway.domain;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -34,23 +35,30 @@ public void add(Section section) {
public void remove(Station station) {
validationRemoveStation(sta... | Java | ์ ์ ํ ์ฌ์ด์ฆ๋ก ๋ฉ์๋๋ฅผ ๋๋์ด ์ฃผ์
จ๋ค์ ๐ |
@@ -0,0 +1,48 @@
+package nextstep.subway.unit;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import nextstep.subway.domain.Line;
+import nextstep.subway.domain.Station;
+import org.springframework.test.util.ReflectionTestUtils;
+
+public class PathFixture {
+ /** (10... | Java | ํฝ์ค์ณ ๋ถ๋ฆฌ๋ฅผ ํตํด ํ
์คํธ ์ฝ๋ ๋ด ํจ๊ณผ์ ์ธ ์ค๋ณต ์ ๊ฑฐ ๐ |
@@ -0,0 +1,120 @@
+package nextstep.subway.acceptance;
+
+import static nextstep.subway.acceptance.LineSteps.์งํ์ฒ _๋
ธ์ _์์ฑ_์์ฒญ;
+import static nextstep.subway.acceptance.LineSteps.์งํ์ฒ _๋
ธ์ ์_์งํ์ฒ _๊ตฌ๊ฐ_์์ฑ_์์ฒญ;
+import static nextstep.subway.acceptance.PathSteps.๊ฒฝ๋ก_์กฐํ_์์ฒญ;
+import static nextstep.subway.acceptance.StationSteps.์งํ์ฒ ์ญ_์... | Java | ๋จ์ ํ
์คํธ์ ํฝ์ค์ณ ๊ด๋ฆฌ ๋ฐฉ๋ฒ์ฒ๋ผ ํด๋น ๊ฐ์ฒด๋ค์ ์ฌ์ฌ์ฉ์ด ํ์ํ ๊ฒฝ์ฐ ์ธ์ ํ
์คํธ์ฉ ํฝ์ค์ณ๋ฅผ ๋ง๋ค์ด์ ๊ด๋ฆฌํ ์ ๋ ์๊ฒ ๋ค์! |
@@ -0,0 +1,28 @@
+package racingcar.domain;
+
+import racingcar.constants.ErrorMsg;
+
+public class CarName {
+ private static final int CAR_NAME_LENGTH_MIN = 1;
+ private static final int CAR_NAME_LENGTH_MAX = 5;
+ private final String name;
+
+ public CarName(String name) {
+ validateLength(name);
... | Java | ์์๊ฐ ํฌ์ฅ ๐ |
@@ -0,0 +1,30 @@
+package racingcar.domain;
+
+public class RacingCar {
+ private final CarName carName;
+ private int moveCount;
+
+ public RacingCar(String name) {
+ this.carName = new CarName(name);
+ moveCount = 0;
+ }
+
+ public int getMoveCount() {
+ return moveCount;
+ }
+
... | Java | ๋๋ค ์ซ์์ ์ํด ์๋์ฐจ์ ์ด๋ ํ๋จ์ญํ ์ด
RacinCar์ ์๋๊ฒ ๋ง๋์ง ํ๋ฒ ์๊ฐํด ๋ณด์๋ฉด ์ข์๊ฑฐ ๊ฐ์์
๐ข |
@@ -0,0 +1,45 @@
+package racingcar.controller;
+
+import racingcar.domain.*;
+import racingcar.view.UIManager;
+
+public class RacingGameController {
+ private UIManager uiManager;
+
+ public void run() {
+ uiManager = new UIManager();
+
+ uiManager.printGameStartMsg();
+ RacingCars racingCa... | Java | ํด๋น controller์์ ์์กด์ฑ ์ฃผ์
์ ๋ํด์ ํ๋ฒ ๊ณ ๋ฏผ ํด๋ณผ ํ์๊ฐ ์์ด์!
controller ๊ณ์ธต์ ์ฌ์ฉํ๊ธฐ์ํด์ ๋ง๋ ๊ฒ์ผ๋ก ๋ณด์ด๋๋ฐ
์ ๊ทผ์ ์ด์๊ฐ ์๋ ๊ฐ์ฒด๋ค์ ์ฌ์ฉํ์ ์ด์ ๊ฐ ์์๊น์ |
@@ -0,0 +1,22 @@
+package racingcar.constants;
+
+public enum ErrorMsg {
+ BLANK_IN_NAME_ERROR("์ด๋ฆ์๋ ๊ณต๋ฐฑ์ด ์์ด์ผ ํ๋ฉฐ ์ผํ(,) ์๋ค์๋ ๊ณต๋ฐฑ์ด ์์ด์ผ ํฉ๋๋ค."),
+ CAR_NAME_LENGTH_MIN_ERROR("์๋์ฐจ ์ด๋ฆ์ " + GameConstants.CAR_NAME_LENGTH_MIN.getNumber() + "์ ์ด์์ด์ด์ผ ํฉ๋๋ค."),
+ CAR_NAME_LENGTH_MAX_ERROR("์๋์ฐจ ์ด๋ฆ์ " + GameConstants.CAR_NAME_LE... | Java | default ์ ๊ทผ ์ ์ด์๋ฅผ ์ฌ์ฉํ์ ์ด์ ๊ฐ ์์๊น์? |
@@ -0,0 +1,16 @@
+package racingcar.constants;
+
+public enum GameConstants {
+ CAR_NAME_LENGTH_MIN(1),
+ CAR_NAME_LENGTH_MAX(5);
+
+ private final int number;
+
+ GameConstants(int number) {
+ this.number = number;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+} | Java | ์ฌ๊ธฐ๋ ์ ญ๊ทผ์ ์ด์๊ฐ!@? |
@@ -0,0 +1,16 @@
+package racingcar.constants;
+
+public enum GameConstants {
+ CAR_NAME_LENGTH_MIN(1),
+ CAR_NAME_LENGTH_MAX(5);
+
+ private final int number;
+
+ GameConstants(int number) {
+ this.number = number;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+} | Java | ํด๋น ํด๋์ค ์ญํ ์ด ๋ชจํธํ์ง ์๋์??
ํด๋์ค ์ด๋ฆ์ ๊ฒ์์ ์ฒด์ ์์๋ฅผ ๊ด๋ฆฌํ๋ ๊ฒ์ผ๋ก ๋ณด์ฌ์ง๋๋ฐ
๋ฉค๋ฒ ๋ณ์๋ ๊ธฐ๋ฅ์ total_count๋ number ์ธํ
๋ ๋ค์ด ์์ด์์ |
@@ -0,0 +1,40 @@
+package racingcar.domain;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import racingcar.constants.ErrorMsg;
+
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.c... | Java | ํ
์คํธ ๋ฉ์๋ ์ด๋ฆ์ด ์ถฉ๋ถํ ๋ช
์์ ์ด๋ผ์
ํด๋น given/when/then ์ฃผ์์ ์์ด๋ ๋ ๊ฑฐ ๊ฐ์์
์กฐ๊ฑด์ด ๋ฐ๋๋๋ง๋ค
์ฃผ์์ ์์ ํด์ฃผ์ง ์์ผ๋ฉด ์ค์ ํ
์คํธ ์ฝ๋์ ์ฃผ์์ด ๋ถ์ผ์น ํ๋ ๊ฒฝ์ฐ๊ฐ ๋ฐ์ ํ ์ ์์ด์ |
@@ -0,0 +1,40 @@
+package racingcar.domain;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import racingcar.constants.ErrorMsg;
+
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.c... | Java | ์ธ๋ถ ์ค๋ฅ ๊ฒ์ฆ ๐ |
@@ -0,0 +1,67 @@
+package racingcar.domain;
+
+import racingcar.constants.ErrorMsg;
+
+import java.util.*;
+
+public class RacingCars {
+ private final List<RacingCar> racingCars;
+
+ public RacingCars(String userInput) {
+ racingCars = new ArrayList<>();
+ createRacingCars(userInput);
+ }
+
+ ... | Java | ์ผ๊ธ์ปฌ๋ ์
ํ์ฉ ๐ฏ |
@@ -0,0 +1,67 @@
+package racingcar.domain;
+
+import racingcar.constants.ErrorMsg;
+
+import java.util.*;
+
+public class RacingCars {
+ private final List<RacingCar> racingCars;
+
+ public RacingCars(String userInput) {
+ racingCars = new ArrayList<>();
+ createRacingCars(userInput);
+ }
+
+ ... | Java | ๋งค๊ฒ๋ณ์๋ฅผ ์ค์ผ ์ ์๋ ๋ฐฉ๋ฒ์ด ์์๊ฑฐ ๊ฐ์๋ฐ ํ๋ฒ ๊ณ ๋ฏผํด๋ด์ฃผ์ธ์ |
@@ -0,0 +1,46 @@
+package racingcar.domain;
+
+import racingcar.constants.ErrorMsg;
+
+public class TrialCount {
+ private final int count;
+
+ public TrialCount(String userInput) {
+ validateEmptyInput(userInput);
+ validateInputType(userInput);
+ count = convertToInt(userInput);
+ va... | Java | ์ค ์ด๋ถ๋ถ ๊ตฌ์กฐ๊ฐ ์ข์๋ณด์ฌ์
์ด๋ ์ซ์๋ฅผ ๊ฐ์ฒด๋ก ํฌ์ฅํด์
validation์ ํ๋ ์์ง๋ ฅ์ด ์๋น์ด ์ข์๋ณด์
๋๋ค. |
@@ -0,0 +1,30 @@
+package racingcar.domain;
+
+public class RacingCar {
+ private final CarName carName;
+ private int moveCount;
+
+ public RacingCar(String name) {
+ this.carName = new CarName(name);
+ moveCount = 0;
+ }
+
+ public int getMoveCount() {
+ return moveCount;
+ }
+
... | Java | GameRule ๋๋ฉ์ธ์ ์ถ๊ฐํ์ฌ ์ ์ง์ฌ๋ถ ํ๋จ ๋ก์ง์ ๋ถ๋ฆฌํ์์ต๋๋ค! |
@@ -0,0 +1,45 @@
+package racingcar.controller;
+
+import racingcar.domain.*;
+import racingcar.view.UIManager;
+
+public class RacingGameController {
+ private UIManager uiManager;
+
+ public void run() {
+ uiManager = new UIManager();
+
+ uiManager.printGameStartMsg();
+ RacingCars racingCa... | Java | ์ ๊ทผ์ ์ด์ private์ผ๋ก ์์ ํ์์ต๋๋ค. |
@@ -0,0 +1,22 @@
+package racingcar.constants;
+
+public enum ErrorMsg {
+ BLANK_IN_NAME_ERROR("์ด๋ฆ์๋ ๊ณต๋ฐฑ์ด ์์ด์ผ ํ๋ฉฐ ์ผํ(,) ์๋ค์๋ ๊ณต๋ฐฑ์ด ์์ด์ผ ํฉ๋๋ค."),
+ CAR_NAME_LENGTH_MIN_ERROR("์๋์ฐจ ์ด๋ฆ์ " + GameConstants.CAR_NAME_LENGTH_MIN.getNumber() + "์ ์ด์์ด์ด์ผ ํฉ๋๋ค."),
+ CAR_NAME_LENGTH_MAX_ERROR("์๋์ฐจ ์ด๋ฆ์ " + GameConstants.CAR_NAME_LE... | Java | Enumํด๋์ค์ ์์ฑ์๋ private๋ง ํ์ฉํ๋ฏ๋ก
์ ๊ทผ์ ์ด์๋ฅผ ์ง์ ํ์ง ์์ผ๋ฉด private์ด ๊ธฐ๋ณธ์ผ๋ก ์ง์ ๋๊ธฐ ๋๋ฌธ์ ๋ฐ๋ก ์ง์ ์ ์ํ์ต๋๋ค!
๋ช
์์ ์ผ๋ก private ํค์๋๋ฅผ ๋ถ์ด๋ ๊ฒ์ด ์ข์๊น์? |
@@ -0,0 +1,16 @@
+package racingcar.constants;
+
+public enum GameConstants {
+ CAR_NAME_LENGTH_MIN(1),
+ CAR_NAME_LENGTH_MAX(5);
+
+ private final int number;
+
+ GameConstants(int number) {
+ this.number = number;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+} | Java | ์์ ErrorMsg์ ๊ฐ์ ์ด์ ๋ก ์ ๊ทผ์ ์ด์๋ฅผ ์ง์ ํ์ง ์์์ต๋๋ค. |
@@ -0,0 +1,16 @@
+package racingcar.constants;
+
+public enum GameConstants {
+ CAR_NAME_LENGTH_MIN(1),
+ CAR_NAME_LENGTH_MAX(5);
+
+ private final int number;
+
+ GameConstants(int number) {
+ this.number = number;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+} | Java | TRIAL_COUNT(์๋ํ์)๋ ๊ฒ์์ ์ฒด ์์ ์ค ํ๋๋ผ๊ณ ์๊ฐํ์๋๋ฐ,
๊ฒ์ ์์ ์ ๋ถํฐ ๊ฒฐ์ ๋๋ ์์์
๊ฒ์ ์์ ํ ๊ฒฐ์ ๋๋ TRIAL_COUNT๋ ์ฐจ์ด์ ์ด ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
TRIAL_COUNT๋ GameConstants์์๋ ์ญ์ ํ๊ณ , TrialCount ๊ฐ์ฒด๋ฅผ ํตํด์ ๊ฐ์ ๋ฐ์์ค๋๋ก ์์ ํ์์ต๋๋ค. |
@@ -0,0 +1,40 @@
+package racingcar.domain;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import racingcar.constants.ErrorMsg;
+
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.c... | Java | ๋ถํ์ํ ์ฃผ์ ์ ๊ฑฐํ์ต๋๋ค! |
@@ -0,0 +1,67 @@
+package racingcar.domain;
+
+import racingcar.constants.ErrorMsg;
+
+import java.util.*;
+
+public class RacingCars {
+ private final List<RacingCar> racingCars;
+
+ public RacingCars(String userInput) {
+ racingCars = new ArrayList<>();
+ createRacingCars(userInput);
+ }
+
+ ... | Java | Winners ๋๋ฉ์ธ์ ์ถ๊ฐํ์ฌ ์ฐ์น์ ์ถ์ถํ๋ ๋ก์ง์ ๋ถ๋ฆฌํ์์ต๋๋ค! |
@@ -0,0 +1,30 @@
+package racingcar.domain;
+
+public class RacingCar {
+ private final CarName carName;
+ private int moveCount;
+
+ public RacingCar(String name) {
+ this.carName = new CarName(name);
+ moveCount = 0;
+ }
+
+ public int getMoveCount() {
+ return moveCount;
+ }
+
... | Java | 1. ๊ธฐ๋ณธ์์ฑ์๋ฅผ ํ์ฉํ ๋๋ฉ์ธ ํ์ฉ์ ๊ธฐ๋ณธ์ ์ผ๋ก ์ข์ ๋ฐฉ๋ฒ์ด ์๋์์. -> ํด๋น ๋๋ฉ์ธ์ ๋๋ฉ์ธ์ด๋ผ๊ธฐ ๋ณด๋จ static method๋ฅผ ํ์ฉ ํ๊ธฐ ์ํ vo ๋ก ์๊ฐ ๋์ ใ
ใ
2. GameRule์ ๋๋ฉ์ธ์ผ๋ก ๊ฐ์ฃผ ํ๋ค๋ฉด, racingcar ->gamerule ์ผ๋ก ์์กด์ฑ์ด ์๊ธฐ๋๋ฐ ํฉ๋ฆฌ์ ์ธ ๊ตฌ์กฐ๋ก ๋ณด์ด์ง๋ ์์์ใ
---------------
ํํธ์ค ๋ด์ฉ์ ์ข๋ ๊ณ ๋ฏผํด๋ณด๋ฉด ์ข์์๊ฑฐ ๊ฐ์์. ๋จ์ํ ํด๋น ๋๋ฉ์ธ์ ์ถ๊ฐํด์ ์ฒ๋ฆฌํ๋๊ฒ์ด ์๋๋ผ
๊ฐ ๋๋ฉ์ธ์ ์ด๋ค์์ผ๋ก ํธ์ถํ๊ณ ์์กด์ฑ ๊ด๋ฆฌํ ์ง ๊ณ ๋ฏผ์ ์ข๋ํด์ ์์ ํด๋ด์ |
@@ -0,0 +1,22 @@
+package racingcar.constants;
+
+public enum ErrorMsg {
+ BLANK_IN_NAME_ERROR("์ด๋ฆ์๋ ๊ณต๋ฐฑ์ด ์์ด์ผ ํ๋ฉฐ ์ผํ(,) ์๋ค์๋ ๊ณต๋ฐฑ์ด ์์ด์ผ ํฉ๋๋ค."),
+ CAR_NAME_LENGTH_MIN_ERROR("์๋์ฐจ ์ด๋ฆ์ " + GameConstants.CAR_NAME_LENGTH_MIN.getNumber() + "์ ์ด์์ด์ด์ผ ํฉ๋๋ค."),
+ CAR_NAME_LENGTH_MAX_ERROR("์๋์ฐจ ์ด๋ฆ์ " + GameConstants.CAR_NAME_LE... | Java | ์ค ์ด๊ฑด ์ ๊ฐ ์ค์ํ๋ค์. ๋๋ฆฌ๋ ๋ง์์ด ๋ง์์! |
@@ -0,0 +1,16 @@
+package racingcar.constants;
+
+public enum GameConstants {
+ CAR_NAME_LENGTH_MIN(1),
+ CAR_NAME_LENGTH_MAX(5);
+
+ private final int number;
+
+ GameConstants(int number) {
+ this.number = number;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+} | Java | GameRule ๋๋ฉ์ธ์ด ๋ง๋ค์ด ์ ธ์, GameConstants์ ์ค๋ณต๋ ์๋ฏธ๋ฅผ ๋ด๋๊ฑฐ ๊ฐ์๋ฐ
ํด๋น ํด๋์ค์ ๋ํด ๊ณ ๋ฏผ์ด ์ข๋ ํ์ํด๋ณด์ฌ์ฉ |
@@ -0,0 +1,30 @@
+package racingcar.domain;
+
+public class RacingCar {
+ private final CarName carName;
+ private int moveCount;
+
+ public RacingCar(String name) {
+ this.carName = new CarName(name);
+ moveCount = 0;
+ }
+
+ public int getMoveCount() {
+ return moveCount;
+ }
+
... | Java | ### ํ์ฌ ์์ ์ฌํญ
- GameRule ๋๋ฉ์ธ์ ๋ฉค๋ฒ๋ณ์๋ก RandomNumber์ TrialCount ์ถ๊ฐ
- RandomNumber๋ ์๋์ฐจ์ ์ ์ง์ฌ๋ถ๋ฅผ ํ๋จํ ๋๋ง ํ์ํ๋ฐ, ์ ์ง์ฌ๋ถ ํ๋จ๋ก์ง์ธ GameRule์ ์์ผ๋ฏ๋ก RandomNumber๋ฅผ GameRule์ ๋ฉค๋ฒ๋ณ์๋ก ์ถ๊ฐํจ
- GameRule ๊ฐ์ฒด๋ฅผ RacingCar์ ๋ฉ์๋ ์์์ ์์ฑํ์ง ์๊ณ Controller์์ ์์ฑํ๋๋ก ์์
- Controller์์ RacingCars์ GameRule๊ฐ์ฒด๋ฅผ ๋งค๊ฐ๋ณ์๋ก ์ ๋ฌ
- GameRandomNumber์ getRandomNumbe... |
@@ -0,0 +1,62 @@
+import InputView from '../view/InputView.js';
+import Benefit from './Benefit.js';
+import Giveaway from './Giveaway.js';
+import OrderAmount from './OrderAmount.js';
+import OrderManager from './OrderManager.js';
+
+class OrderProcessor {
+ static async processOrder() {
+ const { visitDate, order... | JavaScript | ํด๋น ํด๋์ค์ ํจ์๋ค์์ static์ ๋ชจ๋ ๋ถ์ด์
จ๋๋ฐ, static์ ์ ๋ถ์ฌ๋ ๊ด์ฐฎ์ง ์์๊น์?
๋ชจ๋ static์ ๋ถ์ด์ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค! |
@@ -0,0 +1,24 @@
+import Benefit from './Benefit.js';
+
+class OrderAmount {
+ static calculateAmountBeforeDiscount(menusInfo) {
+ return menusInfo.reduce((acc, cur) => acc + cur[1] * cur[2], 0);
+ }
+
+ static calculateDiscountTotalAmount(visitDate, orderMenusInfo, dayOfWeek) {
+ return [
+ Benefit.calcu... | JavaScript | ๊ณ ์ฐจํจ์๋ฅผ ๊ต์ฅํ ์ ์ฐ์๋ค์! ํ์ฉ๋ฒ์ ๋ง์ด ๋ฐฐ์๊ฐ๋๋ค. ๐ |
@@ -0,0 +1,34 @@
+import OutputView from '../view/OutputView.js';
+import OrderProcessor from '../domains/OrderProcessor.js';
+
+class ChristmasEventController {
+ static async start() {
+ OutputView.printGreeting();
+ const processedOrder = await OrderProcessor.processOrder();
+ this.#printOutput(processedOr... | JavaScript | controller์ OrderProcessor๋ฅผ ๋ถ๋ฆฌํ์ ๊ฒ ์ธ์ ๊น์์ต๋๋ค.
์ ๋ ์ด ๋ถ๋ถ์ ๋ง์ด ๊ณ ๋ฏผํ๋๋ฐ์.
์ด๋ฒ ๋ฏธ์
๊ฐ์ ์์ ์ฝ๋์์ ๋๋ฌด ๋๋๋ฉด ์คํ๋ ค ๊ฐ๋
์ฑ์ด ์์ข์์ง๊น ํ์ฌ controller์ OrderProcessor ๊ฐ์ ํจ์๋ค์ ๋ชจ๋ ๋ฃ์๋๋ฐ, ์ ๊ฐ ์๋ชป ์๊ฐํ๊ฑด ์๋๊ฐ ์ถ์ ์ฝ๋์์ต๋๋ค.
controller์ ์ญํ ์ ๋ํ ๊ณ ๋ฏผ์ด ๋ง๋ค์..!
๋ณํ๋๊ป์๋ controller์ ์ญํ ์ Processor๋ฅผ ์คํํ๊ณ , ํด๋น ๋ฐ์ดํฐ๋ฅผ ๋ฐ์์ view๋ก ๋ณด๋ด๋ ์ค๊ฐ์๋ก ๋ณด์ ๊ฒ ๋ง์๊น์? |
@@ -0,0 +1,48 @@
+import CONSTANTS from '../constants/constants.js';
+import MENU from '../constants/menu.js';
+import OrderMenuValidator from '../validators/OrderMenuValidator.js';
+import VisitDateValidator from '../validators/VisitDateValidator.js';
+
+class OrderManager {
+ #visitDate;
+
+ #orderMenus;
+
+ con... | JavaScript | getํจ์์์ ๋จ์ํ get๋ง ํ๋ฉด ์ด๋จ์ง์?
OrderProcessor์์ getํจ์๋ฅผ ํ ๋๋ง๋ค setํจ์๋ค์ ์คํํ๋ ๋นํจ์จ์ ์ด๋ผ ์๊ฐํ์ต๋๋ค. ๋ฌผ๋ก ์ง๊ธ์ ํ๋ฒ๋ง ์คํ์ด ๋์ง๋ง์!
return๋ฌธ์์ ๋ฐ์ดํฐ ๊ฐ๊ณต์ ๋ชจ๋ ํ ํ Processor๋ก ๋ณด๋ด๋ ๊ฒ์ 3์ฃผ์ฐจ ํผ๋๋ฐฑ์์ ๋์จ "getter๋ฅผ getter๋ก๋ง" ๋ด์ฉ์ ๋ง์ด ๊ณ ๋ฏผํ์ ๊ฒ ๊ฐ์ ์ธ์๊น์์ต๋๋ค! |
@@ -0,0 +1,151 @@
+import ERROR from '../../src/constants/error.js';
+import OrderMenuValidator from '../../src/validators/OrderMenuValidator.js';
+
+describe('์ฃผ๋ฌธ ๋ฉ๋ด์ ๊ฐ์ ์
๋ ฅ ์์ธ ์ํฉ ํ
์คํธ', () => {
+ test('๋ฉ๋ดํ์ ์๋ ๋ฉ๋ด์ธ ๊ฒฝ์ฐ undefined๋ฅผ ๋ฐํํ๋ค.', () => {
+ const value = [
+ ['์์ก์ด์ํ', '1'],
+ ['ํํ์ค', '2'],
+ ['๋ฐ๋น... | JavaScript | validator๋ค์ testํ ์๊ฐ์ ํ์ง ๋ชปํ์๋๋ฐ, ๊ต์ฅํ ๊ผผ๊ผผํ ํ
์คํธ์ฝ๋ ์์ฑํ์ ๊ฒ ๊ฐ๋ค์.
ํ๋ ๋ ๋ฐฐ์๊ฐ๋๋ค~! |
@@ -0,0 +1,31 @@
+import { Console } from '@woowacourse/mission-utils';
+import MESSAGE from '../constants/message.js';
+import VisitDateValidator from '../validators/VisitDateValidator.js';
+import OrderMenuValidator from '../validators/OrderMenuValidator.js';
+import reTry from '../utils/reTry.js';
+
+const InputView... | JavaScript | ์ด๊ฒ๋ ํ๋ฒ ํจ๊ป ๊ณ ๋ฏผํด๋ณด๋ฉด ์ข์ ๊ฒ ๊ฐ์๋ฐ, ์ ๋ InputView์์๋ ์ ๋ง input๋ง return์ ํ๊ณ ๋ค๋ฅธ ์ ์ฒ๋ฆฌ๋ ๋ฐ์ดํฐ๋ฅผ ๋ค๋ฃจ๋ ํ์ผ์์ ์ฒ๋ฆฌ๋ฅผ ํด์ฃผ์๋๋ฐ์.
ํน์ ์ด ๋ถ๋ถ์ ์ด๋ป๊ฒ ์๊ฐํ์๋์ง ๊ถ๊ธํฉ๋๋ค.
๋ฐ์ดํฐ ๊ด๋ จ ๋ก์ง์ด ์๋ input ๋ฐ์ ๋ฐ์ดํฐ์ ์ ์ฒ๋ฆฌ๋ inputView์์ ์ฒ๋ฆฌํ๊ณ ์ ํ์ ๊ฑด๊ฐ์?! |
@@ -0,0 +1,24 @@
+package com.example.chatgptcodereviewtest.controller;
+
+import com.example.chatgptcodereviewtest.service.TestService2;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * ์ค๋ช
:
+ *
+ * @author ์ตํ๋ฒ(Jayce) / hb.choi@dreamus.io
+ * @since 2023/03/23
+ */
+... | Java | ์ ์ฝ๋๋ `TestController2`๋ผ๋ REST API ์ปจํธ๋กค๋ฌ ํด๋์ค์
๋๋ค.
๊ฐ์ ์ ์:
1. Javadoc(์ฃผ์) ์์ฑ์ด ํ์ํฉ๋๋ค. ๋ฉ์๋์ ํด๋์ค์ ์ค๋ช
์ ๊ตฌ์ฒด์ ์ผ๋ก ๋ฌ์์ฃผ์ด ๊ฐ๋
์ฑ์ ๋์ผ ์ ์์ต๋๋ค.
2. ๋ง์ง๋ง ์ค์ ๊ฐํ ๋ฌธ์์ด์ด ์์ต๋๋ค. ์์ค์ฝ๋๋ฅผ ์์ ๋ฐ ํธ์งํ ๋ ๊น์๋ฌ๊ฐ ๋ฐ์ํ์ง ์๋๋ก ๊ฐํ ๋ฌธ์์ด์ ์ถ๊ฐํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
3. `@RequestParam` ์ด๋
ธํ
์ด์
์ required ์์ฑ๊ฐ์ false๋ก ๋์ด ์์ด, ํ์๋ก ๋ค์ด์ฌ ๊ฐ์ด ์๋๋๋ค. ์ด์ ๋ํ ์ฒ๋ฆฌ๋ฅผ ํ๊ณ ์ถ๋ค๋ฉด, ํด๋น ํ๋ผ๋ฏธํฐ ๋ณ์์ ๋ ์ฒดํฌ๋ ๋ํดํธ๊ฐ ๋ฑ์ ์ง์ ํด์ผ ... |
@@ -0,0 +1,17 @@
+package com.example.chatgptcodereviewtest.service;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * ์ค๋ช
:
+ *
+ * @author ์ตํ๋ฒ(Jayce) / hb.choi@dreamus.io
+ * @since 2023/03/23
+ */
+@Service
+public class TestService2 {
+
+ public String getUppercaseTestLabel(String label) {
+ retu... | Java | ์ด ์ฝ๋๋ ๋ด์์ ์ธ ๋ฌธ์ ๋ ๋ฒ๊ทธ๊ฐ ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
๋จ์ํ๊ฒ ๋ฌธ์์ด์ ๋๋ฌธ์๋ก ๋ณ๊ฒฝํ๋ ๋ฉ์๋๋ฅผ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ, Spring์ Service ์ด๋
ธํ
์ด์
์ ์ฌ์ฉํ์ฌ Bean์ผ๋ก ๋ฑ๋ก๋์ด ์์ต๋๋ค.
๋ณ์๋ช
๊ณผ ๋ฉ์๋๋ช
์ ์ง๊ด์ฑ ์ธก๋ฉด์์ ๊ฐ์ ํ ์ ์ด ์๋ ๊ฒ ๊ฐ์ต๋๋ค. 'label'์ ๊ตฌ์ฒด์ ์ธ ์๋ฏธ๋ฅผ ์๊ธฐ ์ด๋ ต์ต๋๋ค. ๋ ๊ตฌ์ฒด์ ์ธ ๋ช
์นญ์ ์ฌ์ฉํ๋ค๋ฉด ์ฝ๋์ ๊ฐ๋
์ฑ์ด ํฅ์๋ ๊ฒ์
๋๋ค. |
@@ -0,0 +1,87 @@
+const express = require('express')
+const http = require('http');
+const path = require('path');
+
+const bodyParser = require('body-parser');
+const static = require('serve-static');
+const multer = require("multer")
+
+const app = express();
+
+app.set('port', process.env.PORT || 3000);
+
+app.use(b... | JavaScript | String์ด ์๋ html์ด๋ ejs ํ์ผ๋ก ๋ณด๋ด๋ ๊ฒ์ด ์ข์ต๋๋ค. (Feat. ์ฟ ๋ง์จฉ)
save.ejs๋ก ๋ถ๋ฆฌํด ์ฃผ์ธ์. |
@@ -0,0 +1,87 @@
+const express = require('express')
+const http = require('http');
+const path = require('path');
+
+const bodyParser = require('body-parser');
+const static = require('serve-static');
+const multer = require("multer")
+
+const app = express();
+
+app.set('port', process.env.PORT || 3000);
+
+app.use(b... | JavaScript | ๋น ์ค๊ณผ ๋ค์ฌ์ฐ๊ธฐ ์ ๋ฆฌํด ์ฃผ์ธ์. |
@@ -1,7 +1,10 @@
package christmas;
+import christmas.controller.MainController;
+
public class Application {
public static void main(String[] args) {
- // TODO: ํ๋ก๊ทธ๋จ ๊ตฌํ
+ MainController mainController = new MainController();
+ mainController.run();
}
} | Java | ๊ฐ์ฒด๋ฅผ ์์ฑํ ๋ new ์์ฝ์ด๋ณด๋ค ์ ์ ํฉํ ๋ฆฌ ๋ฉ์๋๋ฅผ ์ฌ์ฉํด๋ณด์๋ฉด ์ด๋จ๊น์. ๊ฐ๋
์ฑ์ด๋ ๊ฐ์ฒด ์์ฑ ์ ์ ํ ๊ฐ์ ์ฌ๋ฌ ๊ฐ์ง ์ด์ ์ด ์์ด์.
https://tecoble.techcourse.co.kr/post/2020-05-26-static-factory-method/ |
@@ -0,0 +1,47 @@
+package christmas.controller;
+
+import java.util.Map;
+
+import christmas.view.*;
+import christmas.model.*;
+
+public class MainController {
+ private OrderMenu orderMenu;
+
+ public MainController() {
+ orderMenu = new OrderMenu();
+ }
+
+ public void run() {
+ orderMenu.s... | Java | OutputView๋ InputView์ ์
์ถ๋ ฅ ๊ธฐ๋ฅ๋ค์ ๋ชจ๋ ์คํํฑ ๋ฉ์๋๋ก ๊ตฌํํ์
จ๋ค์. ๋ณดํต์ ํด๋น ๊ฐ์ฒด๋ฅผ ์์ฑ ํ์ ์ผ๋ฐ ๋ฉ์๋๋ฅผ ํธ์ถํ๋๋ฐ ์คํํฑ ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ ์ด์ ๊ฐ ์์ผ์ค๊น์? |
@@ -0,0 +1,97 @@
+package christmas.util;
+
+import java.util.Map;
+import java.util.List;
+
+public class Validator {
+ private final static char MIN_DIGIT = '0';
+ private final static char MAX_DIGIT = '9';
+ private final static char CHAR_HYPHEN = '-';
+ private final static char CHAR_COMMA = ',';
+ p... | Java | ์ ๋ ์ฑ๊ธฐ์ง ๋ชปํ ๋ถ๋ถ์ด๊ธดํฉ๋๋ค๋ง ํด๋น ๋ด์ฉ ๊ณต์ ํด๋๋ฆฌ์๋ฉด,
'์๋ฃ๋ง ์ฃผ๋ฌธ'๊ณผ ๊ฐ์ ์์ธ์ฒ๋ฆฌ๋ ๋ฌธ์์ด ํ์ฑ ์์ธ๊ฐ ์๋ ๋น์ฆ๋์ค ๋ก์ง ์์ธ์ฒ๋ฆฌ์ด๋ฏ๋ก
๊ฐ์ฒด์์ฑ์์ ์์ธ ์ฒ๋ฆฌ๋ฅผ ํด์ฃผ๋ฉด ์ญํ ๋ถ๋ฆฌ ์์น์ ํจ์ฌ ๋ ์ข์ ์ฝ๋๊ฐ ๋ ๊ฒ ๊ฐ์ต๋๋ค~! |
@@ -1,7 +1,10 @@
package christmas;
+import christmas.controller.MainController;
+
public class Application {
public static void main(String[] args) {
- // TODO: ํ๋ก๊ทธ๋จ ๊ตฌํ
+ MainController mainController = new MainController();
+ mainController.run();
}
} | Java | ์๊ฐํ์ง ๋ชปํ๋ ๊ฐ๋
์ธ๋ฐ ๊ฐ์ฌํฉ๋๋ค! ๋ฆฌํฉํ ๋งํ ๋ ์ ์ฉํ๋ฉด ์ข์ ๊ฒ ๊ฐ๋ค์ |
@@ -0,0 +1,39 @@
+package christmas.util;
+
+public enum Constant {
+ NOT_IN_MENU(-1),
+ EPPETIZER(0),
+ MAINMENU(1),
+ DESSERT(2),
+ BEVERAGE(3),
+ CATEGORY_COUNT(4),
+ ZERO(0),
+ ONE(1),
+ THOUSAND(1000),
+ HUNDRED(100),
+ CHRISTMAS_DAY(25),
+ MIN_BENEFIT_PRICE(10000),
+ PRESENT... | Java | Enum์ ๋ฉ๋ด์ ๋ณด ์ ์ฅํ๋ ์๋ฃ๊ตฌ์กฐ๋ก ์ฌ์ฉํ๋ฉด ์ฉ์ฒ๊ฐ ์ ๋ง์ ๊ฒ ๊ฐ์ต๋๋ค.
๋ฉ๋ด์ ํด๋นํ๋ ํ๊ธ์ด๋ฆ(String)๊ณผ ๊ฐ๊ฒฉ(Integer)๊ฐ ์กด์ฌํ๊ธฐ ๋๋ฌธ์ด์ง์. |
@@ -0,0 +1,68 @@
+package christmas.model;
+
+import christmas.util.Constant;
+import christmas.util.ErrorMessage;
+import christmas.util.Utility;
+import christmas.util.Validator;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.List;
+
+public class OrderMenu {
+ private final List<Map<Strin... | Java | Map.of๋ก ์ด๊ธฐํํ๋ ํธํด๋ณด์ด๋ค์! ๋ฐฐ์ ์ต๋๋ค! ์ด๋๊ฐ์ ์จ๋จน์ด ๋ด์ผ๊ฒ ์ด์! |
@@ -0,0 +1,47 @@
+package christmas.controller;
+
+import java.util.Map;
+
+import christmas.view.*;
+import christmas.model.*;
+
+public class MainController {
+ private OrderMenu orderMenu;
+
+ public MainController() {
+ orderMenu = new OrderMenu();
+ }
+
+ public void run() {
+ orderMenu.s... | Java | MainController๊ฐ ํฌ๊ฒ ์ปจํธ๋กค(๊ฐ์ฒด๋ด ๋ฐ์ดํฐ๋ฅผ ์์ ๋ฐ ์ ์ฅ)ํ๋ ๋ชจ๋ธ์ orderMenu์ธ ๊ฒ ๊ฐ์๋ณด์
๋๋ค. ์ฆ ํด๋์ค ์ด๋ฆ์ด orderController์ด๋ฉด Model๊ณผ Controller๊ฐ์ ์ญํ ์์กด์ฑ์ ๋ ๋ง๋ ์๋ช
์ผ ๊ฒ ๊ฐ์ต๋๋ค |
@@ -0,0 +1,79 @@
+package christmas.model;
+
+import christmas.util.Constant;
+import christmas.util.Message;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Benefit {
+ private int orderDate;
+ private int[] categoryCount;
+ Map<String, Integer> benefits;
+
+ public Benefit(int orderDat... | Java | ์ ์ฒด์ ์ผ๋ก ํจ์๋ถ๋ฆฌ๊ฐ ์ ๋ผ์์ด์ ํจ์๋น ๋ผ์ธ์ด ์งง์ ํธ์ด๋ค์! ๊ต์ฅํ ๊ฐ๋
์ฑ ์ข์ ์ฝ๋๊ฐ ๋ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,39 @@
+package christmas.util;
+
+public enum Constant {
+ NOT_IN_MENU(-1),
+ EPPETIZER(0),
+ MAINMENU(1),
+ DESSERT(2),
+ BEVERAGE(3),
+ CATEGORY_COUNT(4),
+ ZERO(0),
+ ONE(1),
+ THOUSAND(1000),
+ HUNDRED(100),
+ CHRISTMAS_DAY(25),
+ MIN_BENEFIT_PRICE(10000),
+ PRESENT... | Java | ์์๋ค์ enum์ผ๋ก ๊ด๋ฆฌํ์๋ ๊ฒ์ ์ข์ ํฌ์ธํธ์ธ ๊ฒ ๊ฐ์ต๋๋ค. ํ์ง๋ง constant์ ๋ชจ๋ ์์๋ฅผ ๋ค ๋ฃ์ด๋ฒ๋ฆฌ์๋ฉด ๊ฐ๋ณ ์์๋ฅผ ์์ ํ๊ฑฐ๋ ๋ณ๊ฒฝํด์ผ ํ ๋ ์ฐพ๊ธฐ ์ด๋ ค์์ง ๊ฒ ๊ฐ์์. enum์ ์ข
๋ฅ๋ณ๋ก, ๋ฌธ๋งฅ๋ณ๋ก ๋ถ๋ฆฌํ์๋ ๊ฒ์ ์ถ์ฒ ๋๋ ค์. |
@@ -0,0 +1,79 @@
+package christmas.model;
+
+import christmas.util.Constant;
+import christmas.util.Message;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Benefit {
+ private int orderDate;
+ private int[] categoryCount;
+ Map<String, Integer> benefits;
+
+ public Benefit(int orderDat... | Java | ์ค์ ์ ํ๋ฆฌ์ผ์ด์
์์ ๋ฐฐ์ด ๋ณด๋ค๋ ๋ฆฌ์คํธ๋, ๋งต, ์
๋ฑ ์ปฌ๋ ์
๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๋ค๊ณ ํด์. ๊ทธ ์ด์ ๋ ์ง๋ ์ฃผ์ฐจ ํผ๋๋ฐฑ์ ๋ณด๋ฉด ๋ฐฐ์ด๋ณด๋ค ์ข ๋ ํธ๋ฆฌํ ์ฌ๋ฌ API๋ค์ ์ ๊ณตํ๊ธฐ ๋๋ฌธ์ธ๋ฐ์. ์ด์ธ์๋ ์ปฌ๋ ์
์ด ์ ํธ๋๋ ์ด์ ๋ ์ดํํฐ๋ธ ์๋ฐ ๋ฑ์์๋ ์ธ๊ธ๋์ด ์์ต๋๋ค.
https://incheol-jung.gitbook.io/docs/study/effective-java/undefined-3/2020-03-20-effective-28item |
@@ -0,0 +1,68 @@
+package christmas.model;
+
+import christmas.util.Constant;
+import christmas.util.ErrorMessage;
+import christmas.util.Utility;
+import christmas.util.Validator;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.List;
+
+public class OrderMenu {
+ private final List<Map<Strin... | Java | ๋ฉ๋ด ์ด๋ฆ๊ณผ ๊ฐ๊ฒฉ์ ๊ฒฝ์ฐ ํ๋ ์ฝ๋ฉํ๊ธฐ๋ณด๋ค enum ๋ฑ์ผ๋ก ๋ถ๋ฆฌํ์ฌ ๊ด๋ฆฌํ๋ ๊ฒ์ด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,97 @@
+package christmas.util;
+
+import java.util.Map;
+import java.util.List;
+
+public class Validator {
+ private final static char MIN_DIGIT = '0';
+ private final static char MAX_DIGIT = '9';
+ private final static char CHAR_HYPHEN = '-';
+ private final static char CHAR_COMMA = ',';
+ p... | Java | ์ด๋ ๊ฒ ์ ํจ์ฑ ๊ฒ์ฌ ๋ก์ง์ ํ ๊ตฐ๋ฐ์์ ๊ด๋ฆฌํ๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ธ ๊ฒ ๊ฐ์ต๋๋ค. ๊ฐ์ธ์ ์ธ ์๊ฐ์ด์ง๋ง ๋๋ฉ์ธ์์ ์ ํจ์ฑ ๊ฒ์ฌํ๊ฒ ๋๋ฉด ์ ํจ์ฑ ๊ฒ์ฌ ๋ก์ง๋ค์ด ํฉ์ด์ง๋ ๊ฒฝํฅ์ด ์์ด์ ๋ก์ง์ ๋ฐ๋ผ๊ฐ๊ธฐ ์ด๋ ค์ด๋ฐ ์ด๋ ๊ฒ ๋ชจ์๋๋ฉด ์ ํจ์ฑ ๊ฒ์ฌ ๋ฉ์๋๋ค๋ง ํ๋์ ๋ณผ ์ ์์ด์ ์ข์ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,96 @@
+package christmas.view;
+
+import christmas.util.Constant;
+import christmas.util.Message;
+import java.util.Map;
+
+import java.text.DecimalFormat;
+
+public class OutputView {
+ public static void printPreview(int orderDate) {
+ System.out.println("12์ " + orderDate + "์ผ์ ์ฐํ
์ฝ ์๋น์์ ๋ฐ์ ์ด๋ฒคํธ ํ... | Java | ์ถ๋ ฅ ๋ทฐ ๋ฉ์๋์ ์ฃผ๋ฌธ์ด๋ ํ ์ธ ์ ์ฃผ๋ฌธ๊ธ์ก์ ๋ฐ์์ ์ฒ๋ฆฌ ํ ํํ์ด๋ ์ฆ์ ๋ฉ๋ด๋ฅผ ๊ณ์ฐํ๋ ๋ถ๊ธฐ ๋ก์ง์ด ๋ด๊ฒจ ์๋ค์. ์ถ๋ ฅ ๋ทฐ๋ ์ถ๋ ฅ๋ง์ ๋ํ ์ฑ
์์ ๊ฐ์ง๋ ๊ฒ์ด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค. ํํ์ด๋ ์ฆ์ ๋ฉ๋ด๋ฅผ ๊ณ์ฐํ๋ ์ฑ
์์ ๊ฐ๊ฐ์ ๋๋ฉ์ธ ๊ฐ์ฒด๋ก ์ด๋ํ์๋ ๊ฒ ์ด๋จ๊น์? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.