Skip to content

Commit 1f0f448

Browse files
committed
tp9 step 2 solution
1 parent 3cc58af commit 1f0f448

File tree

1 file changed

+9
-1
lines changed
  • tp9/src/main/kotlin/fmt/kotlin/fundamentals

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
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+
35
data class Cellar(
46
val bottles: List<Bottle>
57
) {
@@ -9,5 +11,11 @@ data class Cellar(
911
}
1012
}
1113

12-
fun describeRedBottles() = ""
14+
fun describeRedBottles() = bottles.joinToString("\n") {
15+
it.takeIf { it.color == RED }
16+
?.let {
17+
"Bouteille de ${it.name} de ${it.year}"
18+
}
19+
?: "Bouteille de blanc"
20+
}
1321
}

0 commit comments

Comments
 (0)