Skip to content

Commit

Permalink
refactor: edit it and add new constants
Browse files Browse the repository at this point in the history
  • Loading branch information
feb-dain committed Feb 11, 2023
1 parent d85f954 commit 90ca704
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions src/Constants/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,52 @@ const COMMA = ",";
const LINE_BREAK = "\n";

const GAME_MESSAGE = Object.freeze({
INPUT_CAR_NAME: `경주할 자동치 이름을 입력하세요(이름은 쉼표(,)를 기준으로 구분).${LINE_BREAK}`,
INPUT_CAR_NAME: `경주할 자동차 이름을 입력하세요(이름은 쉼표(,)를 기준으로 구분).${LINE_BREAK}`,
INPUT_TRY_COUNT: `시도할 횟수는 몇회인가요?${LINE_BREAK}`,
RUN_RESULT_MESSAGE: `${LINE_BREAK}실행 결과`,
MOVEMENT_UNIT: "-",
COLON: ":",
GAME_RESULT: "(이)가 최종 우승했습니다.",
});

const MAXIMUM_CAR_NAME_LENGTH = 5;
const CAR_NAME_LENGTH = Object.freeze({
MINIMUM_CAR_NAME_LENGTH: 1,
MAXIMUM_CAR_NAME_LENGTH: 5,
});

const MINIMUM_TRY_COUNT = 1;
const MINIMUM_NUMBER_OF_CARS = 2;
const MOVEMENT_STANDARD_NUMBER = 4;
const LESS_THAN_TEN = 10;

const ERROR_MESSAGE = Object.freeze({
NAME_LENGTH_LIMIT: "5글자 이하로 입력해 주세요.",
MINIMUM_CAR_COUNT: "자동차는 최소 2대 이상 등록해주셔야 합니다.",
NAME_LENGTH_LIMIT: `자동차 이름은 ${CAR_NAME_LENGTH.MINIMUM_CAR_NAME_LENGTH}글자 이상, ${CAR_NAME_LENGTH.MAXIMUM_CAR_NAME_LENGTH}글자 이하로 입력해 주세요.`,
MINIMUM_CAR_COUNT: `자동차는 최소 ${MINIMUM_NUMBER_OF_CARS} 이상 등록해주셔야 합니다.`,
NOT_POSITIVE_NUMBER: "양수를 입력해 주세요.",
INVALID_NAME: "유효한 이름을 입력해 주세요.",
NOT_BLANK: "공백없이 입력해 주세요.",
NAME_DUPLICATE: "중복된 이름은 사용할 수 없습니다.",
});

const REGEX = Object.freeze({
BLANK: / /,
ALPHABET_VALID_KOREAN_NUMBER: /[^a-zA-Z0-9가-힣]/,
ONLY_NUMBER: /[^0-9]/,
});

const MOVEMENT = Object.freeze({
FORWARD_DISTANCE: 1,
FORWARD_CONDITION_NUMBER: 4,
});

module.exports = {
GAME_MESSAGE,
COMMA,
LINE_BREAK,
ERROR_MESSAGE,
MAXIMUM_CAR_NAME_LENGTH,
GAME_MESSAGE,
CAR_NAME_LENGTH,
MINIMUM_TRY_COUNT,
MINIMUM_NUMBER_OF_CARS,
COMMA,
MOVEMENT_STANDARD_NUMBER,
LESS_THAN_TEN,
ERROR_MESSAGE,
REGEX,
MOVEMENT,
};

0 comments on commit 90ca704

Please sign in to comment.