-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathScore.java
40 lines (31 loc) · 1.23 KB
/
Score.java
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
package hi;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class Score {
public Integer LargeScore(Integer pobiLeft, Integer pobiRight, Integer crongLeft, Integer crongRight) {
int largePobiScoreLeft = Calculate(pobiLeft);
int largePobiScoreRight = Calculate(pobiRight);
int largeCrongScoreLeft = Calculate(crongLeft);
int largeCrongScoreRight = Calculate(crongRight);
int largePobiScore = largePobiScoreLeft < largePobiScoreRight ? largePobiScoreRight : largePobiScoreLeft;
int largeCrongScore = largeCrongScoreLeft < largeCrongScoreRight ? largeCrongScoreRight : largeCrongScoreLeft;
Compare compare = new Compare();
int win = compare.CompareScore(largePobiScore, largeCrongScore);
return win;
}
public int Calculate (int score) {
LinkedList<Integer> scoreLists = new LinkedList<>();
while (score > 0) {
scoreLists.push(score % 10);
score /= 10;
}
int add = 0;
int mul = 1;
for (int i = 0; i < scoreLists.size(); i++) {
add += scoreLists.get(i);
mul *= scoreLists.get(i);
}
return add < mul ? mul : add;
}
}