Skip to content

Commit 3cc58af

Browse files
committed
tp9 step 2
1 parent 888e161 commit 3cc58af

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

tp9/src/main/kotlin/fmt/kotlin/fundamentals/Bottle.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,11 @@ package fmt.kotlin.fundamentals
22

33
data class Bottle(
44
val name: String,
5-
val year: Int
6-
)
5+
val year: Int,
6+
val color: WineColor
7+
)
8+
9+
enum class WineColor {
10+
RED,
11+
WHITE
12+
}

tp9/src/main/kotlin/fmt/kotlin/fundamentals/Cellar.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ data class Cellar(
88
"Bouteille de ${name} de ${year}"
99
}
1010
}
11+
12+
fun describeRedBottles() = ""
1113
}

tp9/src/test/kotlin/fmt/kotlin/fundamentals/CellarTest.kt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package fmt.kotlin.fundamentals
22

3+
import fmt.kotlin.fundamentals.WineColor.RED
4+
import fmt.kotlin.fundamentals.WineColor.WHITE
35
import org.junit.jupiter.api.Assertions.*
46
import org.junit.jupiter.api.Test
57
import strikt.api.expectThat
@@ -11,8 +13,8 @@ class CellarTest {
1113
fun `should get bottles description`() {
1214
val description = Cellar(
1315
listOf(
14-
Bottle("Coucheroy", 2005),
15-
Bottle("Pedesclaux", 2009)
16+
Bottle("Coucheroy", 2005, RED),
17+
Bottle("Pedesclaux", 2009, RED)
1618
)
1719
).describeBottles()
1820

@@ -21,4 +23,21 @@ class CellarTest {
2123
Bouteille de Pedesclaux de 2009
2224
""".trimIndent())
2325
}
26+
27+
@Test
28+
fun `should get red bottles description`() {
29+
val description = Cellar(
30+
listOf(
31+
Bottle("Coucheroy", 2005, RED),
32+
Bottle("Camarsac", 2018, WHITE),
33+
Bottle("Pedesclaux", 2009, RED),
34+
)
35+
).describeRedBottles()
36+
37+
expectThat(description).isEqualTo("""
38+
Bouteille de Coucheroy de 2005
39+
Bouteille de blanc
40+
Bouteille de Pedesclaux de 2009
41+
""".trimIndent())
42+
}
2443
}

0 commit comments

Comments
 (0)