forked from woowacourse-precourse/java-baseball-6
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathGo.java
More file actions
34 lines (32 loc) · 839 Bytes
/
Go.java
File metadata and controls
34 lines (32 loc) · 839 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
31
32
33
34
package baseball;
import java.util.List;
public class Go {
public String Check(List<Integer> computer, int[] input){
int strike = 0;
int ball = 0;
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
if(computer.get(i).equals(input[j])){
if(i == j){
strike++;
}
else{
ball++;
}
}
}
}
if(ball == 0 && strike == 0){
return "낫싱";
}
else if(strike == 0){
return ball + "볼";
}
else if(ball == 0){
return strike + "스트라이크";
}
else{
return ball + "볼 " + strike + "스트라이크";
}
}
}