This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bowling | |
import org.scalacheck.Gen | |
import org.scalatest.{ShouldMatchers, FlatSpec} | |
import org.scalatest.prop.PropertyChecks | |
class BowlingTest extends FlatSpec with ShouldMatchers with PropertyChecks { | |
val rolls = Gen.chooseNum(0, Game.TotalPins) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bowling | |
object Game { | |
val TotalPins = 10 | |
val TotalFrames = 10 | |
def scoreFor(line: Line): Int = sum(line.rolls, TotalFrames) | |
private def sum(rolls: Seq[Int], remainingFrames: Int): Int = | |
if (remainingFrames == 0) 0 |