Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[이동현] up nd down 구현 #9

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

D5ng
Copy link

@D5ng D5ng commented Feb 1, 2025

✅ 요구사항

  • [ x ] 게임을 시작하면 컴퓨터는 1부터 50 사이의 랜덤 숫자를 생성한다.
  • [ x ] 사용자는 숫자를 추측하여 입력한다. 입력마다 "업", "다운", "정답!" 중 하나를 출력한다.
  • [ x ] 사용자의 이전 추측들을 보여준다.
  • [ x ] 사용자는 최대 5번까지 정답을 맞출 수 있으며, 5회 이내동안에는 맞출 때까지 반복한다.
  • [ x ] 게임이 끝나면 사용자가 몇 회만에 맞췄는지 출력한다.
  • [ x ] 게임을 재시작하거나 종료할 수 있는 옵션을 제공한다.

📝 구현 내용

게임을 구현함에 있어, 중복 로직 관리 및 가독성을 고려하여 코드를 작성했습니다. 나름대로 기능 요구사항을 세세하게 나눠 작업을 했지만, 여전히 복잡하다고 느껴지네요. (개인적으로 가독성이 좋다는 느낌을 받지 못했습니다)

  • 게임 룰(숫자 범위)에 벗어났을 때, 게임을 강제 종료하지 않고, 다시 시작할 수 있도록 구현했습니다.
  • 구현에 필요한 Helper 함수들을 나눠 작업하였습니다.
  • 프롬프트 메세지의 색상이 단조로워 색상을 추가해 강조해봤습니다.

Copy link

@kich555 kich555 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전체적으로 깔끔하고 좋은것 같습니다 . 고생하셨어요

@@ -1,3 +1,14 @@
export const MAX_NUMBER = 50
export const MIN_NUMBER = 1
export const LIMIT_COUNT = 5

export const PRINT = Object.freeze({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍👍 객체로 관리하는것, Object.freeze를 통해 객체 내부의 값들도 상수화 한 부분이 좋네요

Comment on lines +10 to +16
"rules": {
"no-console": "off",
"no-use-before-define": "off",
"no-plusplus": "off",
"no-shadow": "off",
"import/prefer-default-export": "off"
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint를 조금 빡빡하게 ? 사용해보는 것도 좋을것 같아요
가령 airbnb 의 lint rule을 도입해본다던지
참고로 off 처리한 rule들은 리즈너블 해보입니다

Comment on lines +1 to +17
/**
* 게임에서 사용되는 최대 숫자
* @constant
*/
export const MAX_NUMBER = 50

/**
* 게임에서 사용되는 최소 숫자
* @constant
*/
export const MIN_NUMBER = 1

/**
* 숫자 추측 가능 횟수 제한
* @constant
*/
export const LIMIT_COUNT = 5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개인적으로 주석이 전체적으로 조금 과한것 같군요 😅

Comment on lines +4 to +6
let prevInputList = []
let playCount = 0
let answer = getRandomNumber(1, 50)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전역변수가 현재 3개인데 이걸 하나의 상태로 묶어서 관리해보면 어떨까요?
가장 기본적으로는

const playState = {
  prevInputList: [],
  playCount: 0,
  answer: getRandomNumber(1, 50)
}

뭐 이런식으로요

Comment on lines +49 to +51
function userInputValidation(value) {
return value >= MIN_NUMBER && value <= MAX_NUMBER
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value로 문자열 등 숫자가 아닌 다른 값이 올때에 대한 방어코드도 있으면 좋을것 같네요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants