diff --git a/tp9/src/main/kotlin/fmt/kotlin/fundamentals/Bottle.kt b/tp9/src/main/kotlin/fmt/kotlin/fundamentals/Bottle.kt index dbb6845..a3c5b82 100644 --- a/tp9/src/main/kotlin/fmt/kotlin/fundamentals/Bottle.kt +++ b/tp9/src/main/kotlin/fmt/kotlin/fundamentals/Bottle.kt @@ -2,5 +2,11 @@ package fmt.kotlin.fundamentals data class Bottle( val name: String, - val year: Int -) \ No newline at end of file + val year: Int, + val color: WineColor +) + +enum class WineColor { + RED, + WHITE +} \ No newline at end of file diff --git a/tp9/src/main/kotlin/fmt/kotlin/fundamentals/Cellar.kt b/tp9/src/main/kotlin/fmt/kotlin/fundamentals/Cellar.kt index 63e6393..a203d30 100644 --- a/tp9/src/main/kotlin/fmt/kotlin/fundamentals/Cellar.kt +++ b/tp9/src/main/kotlin/fmt/kotlin/fundamentals/Cellar.kt @@ -8,4 +8,6 @@ data class Cellar( "Bouteille de ${name} de ${year}" } } + + fun describeRedBottles() = "" } \ No newline at end of file diff --git a/tp9/src/test/kotlin/fmt/kotlin/fundamentals/CellarTest.kt b/tp9/src/test/kotlin/fmt/kotlin/fundamentals/CellarTest.kt index 22ed7b8..4327ab0 100644 --- a/tp9/src/test/kotlin/fmt/kotlin/fundamentals/CellarTest.kt +++ b/tp9/src/test/kotlin/fmt/kotlin/fundamentals/CellarTest.kt @@ -1,5 +1,7 @@ package fmt.kotlin.fundamentals +import fmt.kotlin.fundamentals.WineColor.RED +import fmt.kotlin.fundamentals.WineColor.WHITE import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import strikt.api.expectThat @@ -11,8 +13,8 @@ class CellarTest { fun `should get bottles description`() { val description = Cellar( listOf( - Bottle("Coucheroy", 2005), - Bottle("Pedesclaux", 2009) + Bottle("Coucheroy", 2005, RED), + Bottle("Pedesclaux", 2009, RED) ) ).describeBottles() @@ -21,4 +23,21 @@ class CellarTest { Bouteille de Pedesclaux de 2009 """.trimIndent()) } + + @Test + fun `should get red bottles description`() { + val description = Cellar( + listOf( + Bottle("Coucheroy", 2005, RED), + Bottle("Camarsac", 2018, WHITE), + Bottle("Pedesclaux", 2009, RED), + ) + ).describeRedBottles() + + expectThat(description).isEqualTo(""" + Bouteille de Coucheroy de 2005 + Bouteille de blanc + Bouteille de Pedesclaux de 2009 + """.trimIndent()) + } } \ No newline at end of file