-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathOutputView.java
More file actions
27 lines (22 loc) · 931 Bytes
/
Copy pathOutputView.java
File metadata and controls
27 lines (22 loc) · 931 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
package baseball.view;
import baseball.model.computer.RandomNumberGenerator;
import baseball.model.computer.Score;
public class OutputView {
private static final String WIN_MESSAGE = "%d개의 숫자를 모두 맞히셨습니다! 게임종료";
public void printScore(Score score){
int ball = score.getBalls();
int strike = score.getStrike();
if(ball == 0 && strike==0) {
System.out.println("낫싱");
}else if(strike == RandomNumberGenerator.NUMBER_LENGTH){
System.out.println(strike+"스트라이크");
System.out.println(String.format(WIN_MESSAGE,RandomNumberGenerator.NUMBER_LENGTH));
}else if(ball==0){
System.out.println(strike+"스트라이크");
}else if(strike==0){
System.out.println(ball+"볼");
}else{
System.out.println(ball+"볼 "+strike+"스트라이크");
}
}
}