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

Joseph415 #189

Closed
wants to merge 16 commits into from
Closed

Joseph415 #189

wants to merge 16 commits into from

Conversation

joseph415
Copy link


Class Baseball 의 메서드

  • Baseball(): 난수를 생성하여 랜덤으로 3자리 숫자를 만드는 생성자,중복숫자와 '0'은 저장하지않음.
  • makeInput(): 사용자로부터 입력을 받는 함수이다. 스캐너를 이용해 console로 입력받는다.
  • check(): 각 자리를 채크하며 스크라이크와 볼의 개수를 구하는 가장 중요한 함수이다.반복문을 break 할수 있게 스트라이크 값을 리턴한다,
    사용자에게 0또는 중복숫자는 다시 입력할수있게 -1를 리턴함.
  • start(): 실행하는 함수이다. start를 통해 각 매소드를 실행시킨다.

다음과 같이 게임을 구성하는 클레스를 만들고 메서드를 구현하였습니다.
사용자는 입력을 할때 중복숫자와 0을 입력할경우 check()메서드에서 판단하여 -1를 리턴해
재입력을 하게 만들었습니다.
check()에서 정답을 맞출 경우 3을 리턴해서 정답을 맞출떄까지 무한으로 도는 loop를 탈출하게 하고
1 과 2를 입력 받아 게임을 재시작할지 결정을 하게 만들었습니다.

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.

None yet

2 participants