-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathConsole.java
More file actions
30 lines (27 loc) · 915 Bytes
/
Console.java
File metadata and controls
30 lines (27 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package baseball;
import java.util.Scanner;
public class Console {
public String getInput() {
System.out.print("숫자를 입력해주세요 : ");
Scanner scanner = new Scanner(System.in);
return scanner.next();
}
public void printResult(int strike, int ball) {
if (strike + ball == 0) {
System.out.print("낫씽");
}
if (strike != 0) {
System.out.print(strike + " 스트라이크 ");
}
if (ball != 0) {
System.out.print(ball + " 볼");
}
System.out.println();
}
public int endGame() {
System.out.println("3개의 숫자를 모두 맞히셨습니다! 게임 종료");
System.out.println("게임을 새로 시작하시려면 1, 종료하려면 2를 입력하세요.");
Scanner scanner = new Scanner(System.in);
return scanner.nextInt();
}
}