Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fkino committed Jan 11, 2017
1 parent 7a3c0f4 commit 59a91d3
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/main/java/bowlingscore/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import java.util.Arrays;

public class Game {
static private int GAME_FRAMES = 10;
static private int FRAME_THROW_COUNT = 2;
static private int TEN_FRAME_THROW_COUNT = 3;
static private int TEN_FRAME_THROW_TOTAL_COUNT = (GAME_FRAMES - 1) * FRAME_THROW_COUNT;
private static final int GAME_FRAMES = 10;
private static final int FRAME_THROW_COUNT = 2;
private static final int TEN_FRAME_THROW_COUNT = 3;
private static final int TEN_FRAME_THROW_TOTAL_COUNT = (GAME_FRAMES - 1) * FRAME_THROW_COUNT;

private Frame frame;

Expand All @@ -25,15 +25,10 @@ public int[] score() {
int[] score = new int[GAME_FRAMES];
int totalScore = 0;

for (int i = 0; i < score.length; i++) {
score[i] = frame.score() + totalScore;
for (int i = 0; i < score.length && frame != null; i++) {
totalScore += frame.score();
score[i] = totalScore;
frame = frame.next();
if (frame == null) {
// 10フレームまでなかった場合
// 例外にしたい
break;
}
totalScore = score[i];
}

return score;
Expand Down

0 comments on commit 59a91d3

Please sign in to comment.