Skip to content

Commit

Permalink
tp5 step 2 solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ctruchi committed Feb 12, 2025
1 parent a8472d4 commit bd85a50
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tp5/src/main/kotlin/fmt/kotlin/fundamentals/Bottle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@ package fmt.kotlin.fundamentals

data class Bottle(
val name: String,
val year: Int
val year: Int,
val color: WineColor
) {

fun isEqualTo(bottle: Bottle) = this == bottle

fun isSameInstance(bottle: Bottle) = this === bottle

override fun toString() = "Bouteille de $name ${color.translate()} de $year"
}

enum class WineColor {
RED,
WHITE;

fun translate() = when (this) {
RED -> "rouge"
WHITE -> "blanc"
}
}

0 comments on commit bd85a50

Please sign in to comment.