-
Notifications
You must be signed in to change notification settings - Fork 906
Expand file tree
/
Copy pathResult.java
More file actions
29 lines (25 loc) · 909 Bytes
/
Result.java
File metadata and controls
29 lines (25 loc) · 909 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
package com.baseball;
import com.domain.Baseballs;
import com.ui.Output;
public class Result {
private static final int Count_Zero = 0;
private int strikeNumber;
private int ballNumber;
public Result(Baseballs computerBaseballs, Baseballs userBaseballs){
strikeNumber = computerBaseballs.countStrike(userBaseballs);
ballNumber = computerBaseballs.countBall(userBaseballs);
}
public String getResult(){
StringBuilder sb = new StringBuilder();
if (strikeNumber == Count_Zero && ballNumber == Count_Zero){
sb.append(Output.RESULT_NOTHING_MESSAGE);
}
if (strikeNumber != Count_Zero){
sb.append(strikeNumber).append(Output.RESULT_STRIKE_MESSAGE);
}
if (ballNumber != Count_Zero){
sb.append(ballNumber).append(Output.RESULT_BALL_MESSAGE);
}
return sb.toString();
}
}