public class Game {

	private int[] rolls = new int[21];
	private int currentRoll = 0;

	public void roll(int pins) {
		rolls[currentRoll++] = pins;

	}

	public int score() {
		int score = 0;
	    int frameIndex = 0;
	    for (int frame = 0; frame < 10; frame++) {
	      if (rolls[frameIndex] == 10) // strike
	      {
	        score += 10 +
	                 rolls[frameIndex+1] +
	                 rolls[frameIndex+2];
	        frameIndex++;
	      }
	      else if (isSpare(frameIndex))
	      {
	        score += 10 + rolls[frameIndex + 2];
	        frameIndex += 2;
	      } else {
	        score += rolls[frameIndex] +
	                 rolls[frameIndex + 1];
	        frameIndex += 2;
	      }
	    }
	    return score;
	}

	private boolean isSpare(int frameIndex) {
		return rolls[frameIndex] + 
	          rolls[frameIndex + 1] == 10;
	}

}

@@ -170,17 +170,20 @@
 re() %7B%0A%09
-%09
+    
 int scor
@@ -343,73 +343,21 @@
 10 +
-%0A%09                 rolls%5BframeIndex+1%5D +%0A%09                 rolls%5B
+ strikeBonus(
 fram
@@ -366,11 +366,9 @@
 ndex
-+2%5D
+)
 ;%0A%09 
@@ -396,23 +396,16 @@
 %09      %7D
-%0A%09     
  else if
@@ -426,23 +426,16 @@
 eIndex))
-%0A%09     
  %7B%0A%09    
@@ -452,22 +452,27 @@
 += 10 + 
-rolls%5B
+spareBonus(
 frameInd
@@ -477,13 +477,9 @@
 ndex
- + 2%5D
+)
 ;%0A%09 
@@ -536,22 +536,56 @@
 core += 
-rolls%5B
+sumOfBallsInFrame(frameIndex);%0A%09        
 frameInd
@@ -590,19 +590,22 @@
 ndex
-%5D
  +
+= 2;
 %0A%09      
     
@@ -604,51 +604,212 @@
     
+%7D%0A%09
     
+%7D%0A%09
     
-   rolls%5BframeIndex + 1%5D;%0A%09        
+return score;%0A%09  %7D%0A%0A%09  private int sumOfBallsInFrame(int frameIndex) %7B%0A%09    return rolls%5BframeIndex%5D+rolls%5BframeIndex+1%5D;%0A%09  %7D%0A%0A%09  private int spareBonus(int frameIndex) %7B%0A%09    return rolls%5B
 fram
@@ -820,53 +820,126 @@
 ex +
-=
  2
+%5D
 ;%0A%09  
-    
 %7D%0A
+%0A
 %09  
-  %7D%0A%09    return score
+private int strikeBonus(int frameIndex) %7B%0A%09    return rolls%5BframeIndex+1%5D+rolls%5BframeIndex+2%5D
 ;%0A%09
+  
 %7D%0A%0A%09
+  
 priv
@@ -977,17 +977,20 @@
 dex) %7B%0A%09
-%09
+    
 return r
@@ -1009,23 +1009,9 @@
 dex%5D
- + %0A%09          
++
 roll
@@ -1022,19 +1022,17 @@
 ameIndex
- + 
++
 1%5D == 10
@@ -1034,13 +1034,14 @@
 == 10;%0A%09
+  
 %7D
-%0A
 %0A%7D%0A

test 5 refactor