Skip to content

Commit a983470

Browse files
committed
feat(kata): new kata the bowling game
1 parent 38dcaab commit a983470

File tree

7 files changed

+97
-0
lines changed

7 files changed

+97
-0
lines changed

BowlingGame/.scalafmt.conf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version=3.5.8
2+
3+
# Only format files tracked by git.
4+
project.git = true
5+
6+
maxColumn = 120
7+
8+
runner.dialect = scala213
9+
10+
trailingCommas = preserve
11+
12+
literals.long = Upper
13+
literals.float = Upper
14+
literals.double = Upper
15+
16+
continuationIndent {
17+
callSite = 2
18+
defnSite = 2
19+
}
20+
21+
danglingParentheses.preset = true
22+
23+
newlines {
24+
avoidAfterYield = false
25+
sometimesBeforeColonInMethodReturnType = false
26+
}
27+
28+
spaces {
29+
inImportCurlyBraces = true
30+
}
31+
32+
align.preset = none
33+
34+
docstrings {
35+
style = SpaceAsterisk
36+
wrap = no
37+
}
38+
39+
rewrite {
40+
rules = [SortImports, RedundantParens, SortModifiers]
41+
}

BowlingGame/build.sbt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
val javaVersion = "11"
2+
val appScalaVersion = "2.13.6"
3+
4+
scalacOptions ++= Seq(
5+
"-unchecked",
6+
"-deprecation",
7+
"-feature",
8+
"-Ywarn-dead-code",
9+
)
10+
11+
lazy val root = (project in file("."))
12+
.settings(
13+
inThisBuild(List(
14+
organization := "com.kpler",
15+
scalaVersion := appScalaVersion,
16+
)),
17+
name := "BowlingGame"
18+
)
19+
20+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.7" % Test
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.6.2

BowlingGame/project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.2.1")

BowlingGame/readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Challenge: Bowling game kata.
2+
3+
https://kata-log.rocks/bowling-game-kata
4+
5+
## Bowling Rules
6+
The game consists of 10 frames. In each frame the player has two rolls to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares.
7+
8+
A spare is when the player knocks down all 10 pins in two rolls. The bonus for that frame is the number of pins knocked down by the next roll.
9+
10+
A strike is when the player knocks down all 10 pins on his first roll. The frame is then completed with a single roll. The bonus for that frame is the value of the next two rolls.
11+
12+
In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame. However no more than three balls can be rolled in tenth frame.
13+
14+
## Requirements
15+
Write a class Game that has two methods
16+
17+
- void roll(int) is called each time the player rolls a ball. The argument is the number of pins knocked down.
18+
- int score() returns the total score for that game.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Main {
2+
def main(args: Array[String]): Unit = {
3+
println("Hello World!")
4+
}
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import org.scalatest._
2+
import flatspec._
3+
import matchers._
4+
5+
class Example extends AnyFlatSpec with should.Matchers {
6+
7+
"A List" should "drop the first values" in {
8+
val stack = List(3, 2)
9+
stack.drop(1) should be (List(2))
10+
}
11+
}

0 commit comments

Comments
 (0)