숫자 야구 게임 미션 제출합니다. ( 고석준 rowan.ko )#198
Open
seokjun-ko wants to merge 9 commits intonext-step:mainfrom
Open
Conversation
added 9 commits
January 28, 2026 16:54
프로젝트의 개요 및 설계 내용을 포함한 README.md 파일 추가. 주요 내용은 다음과 같음: - 프로젝트 소개: JUnit5와 MVC 패턴을 활용한 숫자 야구 게임 - 아키텍처 설계: Model, View, Controller 역할 정의 - 주요 기능: 정답 생성, 힌트 계산, 입출력 UI, 게임 흐름 제어, 예외 처리 - 테스트 계획: JUnit5와 AssertJ를 활용한 도메인 로직 단위 테스트 - 실행 방법 및 예시 안내
상대의 정답을 맞추는 것이기 때문에, 정답을 따로 생성할 필요가 없음
숫자 리스트를 래핑(Wrapping)하여 관리하고, 상대방의 숫자와 비교하는 compare 메서드 구현. - 위치와 값이 같으면 스트라이크 카운트 증가 - 값만 포함되어 있으면 볼 카운트 증가 - 최종 결과를 GameResult 객체로 반환
난수 생성기가 게임 규칙에 맞는 숫자를 반환하는지 검증하는 테스트 추가. - 생성된 리스트의 크기가 3인지 검증 - 모든 숫자가 1~9 범위 내에 있는지 검증 - 서로 다른 숫자로 구성되어 있는지(중복 제거) 검증
1부터 9까지의 서로 다른 임의의 수 3개를 생성하는 로직 구현. - Random 클래스를 사용하여 난수 생성 - 중복 확인 메서드(addIfUnique)를 통해 리스트 내 중복 방지 - 목표 크기(3개)가 될 때까지 반복하여 리스트 완성
Model과 View를 연결하여 전반적인 게임 로직을 수행하는 컨트롤러 추가. 주요 구현 내용은 다음과 같음: - run(): 메인 게임 루프 실행 및 재시작 여부 관리 - parseInput(): 입력값 유효성 검증 (3자리, 1~9 숫자, 중복 여부 확인) - playTurn(): 사용자 입력 처리, 결과 판정, View 업데이트 - 예외 처리: 잘못된 입력 시 에러 메시지 출력 후 로직 유지
게임 진행 상황과 결과를 콘솔에 출력하는 뷰 클래스 추가. - printResult(): GameResult 객체를 받아 볼/스트라이크/낫싱 형식으로 포맷팅하여 출력 - printErrorMessage(): 예외 발생 시 "[ERROR]" 접두사를 붙여 에러 메시지 출력 - 게임 시작 및 종료 문구 출력 메서드 구현
Scanner를 사용하여 콘솔 입력을 받는 InputView 클래스 추가. - readNumbers(): 사용자에게 안내 메시지를 출력하고 숫자 입력을 받음 - readRestartCommand(): 게임 종료 후 재시작(1) 또는 종료(2) 명령어를 입력받음
어플리케이션의 진입점(main 메서드)을 작성하여 게임을 실행. BaseballController 인스턴스를 생성하고 run() 메서드를 호출하여 전체 로직을 수행함.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.