-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathGameView.java
More file actions
49 lines (39 loc) · 1.34 KB
/
GameView.java
File metadata and controls
49 lines (39 loc) · 1.34 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package view;
import model.GameAnswerType;
import java.io.*;
public class GameView {
private static final String TURN_MSG = "숫자를 입력해주세요 : ";
private static final String SINGLE_GAME_END_MSG = "3개의 숫자를 모두 맞히셨습니다! 게임 끝\n 게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요.\n";
private static final String GAME_END_MSG = "게임을 완전히 종료합니다.";
private final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
public void printTurnMsg() throws IOException {
bw.write(TURN_MSG);
bw.flush();
}
public void printResult(GameAnswerType result) throws IOException {
bw.write(result.getAnswer());
bw.newLine();
bw.flush();
}
public void printSingleGameEndMsg() throws IOException {
bw.write(SINGLE_GAME_END_MSG);
bw.flush();
}
public void printGameEndMsg() throws IOException {
bw.write(GAME_END_MSG);
bw.flush();
}
public void printErrorMsg(String message) {
try {
bw.write(message);
bw.newLine();
bw.flush();
}
catch (IOException e) {
System.out.println(message);
}
}
public void releaseResource() throws IOException {
bw.close();
}
}