-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathResult.java
More file actions
39 lines (33 loc) · 951 Bytes
/
Result.java
File metadata and controls
39 lines (33 loc) · 951 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
35
36
37
38
39
package baseball.domain;
public class Result {
private final ResultType resultType;
private final int strike;
private final int ball;
public Result(ComputerNumbers computerNumbers, Numbers inputNumbers) {
int strike = 0;
int ball = 0;
for (int idx = 0; idx < inputNumbers.size(); idx++) {
Number number = inputNumbers.get(idx);
if (computerNumbers.notContain(number)) {
continue;
}
if (number.isSameValue(computerNumbers.get(idx))) {
strike++;
continue;
}
ball++;
}
this.strike = strike;
this.ball = ball;
this.resultType = ResultType.getResult(strike, ball);
}
public ResultType getResultType() {
return resultType;
}
public int getStrike() {
return strike;
}
public int getBall() {
return ball;
}
}