Skip to content

Commit

Permalink
Raindrops - use object instead of an instance - refs exercism#242. Ad…
Browse files Browse the repository at this point in the history
…d Raindrops.scala - refs exercism#137. Add topics to config.json - refs exercism#125
  • Loading branch information
ricemery committed Dec 15, 2016
1 parent 29079be commit 81bed09
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
3 changes: 3 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@
"slug": "raindrops",
"difficulty": 1,
"topics": [
"StrinAgs",
"Logic",
"Transforming"
]
},
{
Expand Down
6 changes: 1 addition & 5 deletions exercises/raindrops/example.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Raindrops {
object Raindrops {
private val sounds = List((3, "Pling"), (5, "Plang"), (7, "Plong"))

def convert(n: Int): String =
Expand All @@ -7,7 +7,3 @@ class Raindrops {
case s => s
}
}

object Raindrops {
def apply() = new Raindrops
}
4 changes: 4 additions & 0 deletions exercises/raindrops/src/main/scala/Raindrops.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object Raindrops {
def convert(n: Int): String = ???
}

32 changes: 16 additions & 16 deletions exercises/raindrops/src/test/scala/RaindropsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,82 @@ import org.scalatest.{Matchers, FlatSpec}

class RaindropsTest extends FlatSpec with Matchers {
it should "convert 1" in {
Raindrops().convert(1) should equal("1")
Raindrops.convert(1) should equal("1")
}

it should "convert 3" in {
pending
Raindrops().convert(3) should equal("Pling")
Raindrops.convert(3) should equal("Pling")
}

it should "convert 5" in {
pending
Raindrops().convert(5) should equal("Plang")
Raindrops.convert(5) should equal("Plang")
}

it should "convert 7" in {
pending
Raindrops().convert(7) should equal("Plong")
Raindrops.convert(7) should equal("Plong")
}

it should "convert 6" in {
pending
Raindrops().convert(6) should equal("Pling")
Raindrops.convert(6) should equal("Pling")
}

it should "convert 9" in {
pending
Raindrops().convert(9) should equal("Pling")
Raindrops.convert(9) should equal("Pling")
}

it should "convert 10" in {
pending
Raindrops().convert(10) should equal("Plang")
Raindrops.convert(10) should equal("Plang")
}

it should "convert 14" in {
pending
Raindrops().convert(14) should equal("Plong")
Raindrops.convert(14) should equal("Plong")
}

it should "convert 15" in {
pending
Raindrops().convert(15) should equal("PlingPlang")
Raindrops.convert(15) should equal("PlingPlang")
}

it should "convert 21" in {
pending
Raindrops().convert(21) should equal("PlingPlong")
Raindrops.convert(21) should equal("PlingPlong")
}

it should "convert 25" in {
pending
Raindrops().convert(25) should equal("Plang")
Raindrops.convert(25) should equal("Plang")
}

it should "convert 35" in {
pending
Raindrops().convert(35) should equal("PlangPlong")
Raindrops.convert(35) should equal("PlangPlong")
}

it should "convert 49" in {
pending
Raindrops().convert(49) should equal("Plong")
Raindrops.convert(49) should equal("Plong")
}

it should "convert 52" in {
pending
Raindrops().convert(52) should equal("52")
Raindrops.convert(52) should equal("52")
}

it should "convert 105" in {
pending
Raindrops().convert(105) should equal("PlingPlangPlong")
Raindrops.convert(105) should equal("PlingPlangPlong")
}

it should "convert 12121" in {
pending
Raindrops().convert(12121) should equal("12121")
Raindrops.convert(12121) should equal("12121")
}
}

0 comments on commit 81bed09

Please sign in to comment.