Skip to content

Commit 2be0274

Browse files
ctruchiCLOVIS-AI
authored andcommitted
tp4 step 6 solution
1 parent 367ae90 commit 2be0274

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tp4/src/main/kotlin/fmt/kotlin/fundamentals/Container.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sealed class Container(
66
) {
77
val valid = (possibleCapacities).contains(capacity)
88

9-
val equipments: List<String> = emptyList()
9+
open val equipments: List<String> = emptyList()
1010

1111
open fun containersNeededToPourIn(container: Container) = capacity / container.capacity
1212
}
@@ -15,14 +15,17 @@ class Barrel(
1515
capacity: Int
1616
) : Container(capacity, 20000..40000) {
1717

18+
override val equipments = listOf("Robinet", "Bonde")
19+
1820
override fun containersNeededToPourIn(container: Container) = when (container) {
1921
is Barrel, is Tank -> -1
2022
else -> super.containersNeededToPourIn(container)
2123
}
2224
}
2325

2426
class Tank(
25-
capacity: Int
27+
capacity: Int,
28+
override val equipments: List<String>
2629
) : Container(capacity, 2000000..10000000) {
2730

2831
override fun containersNeededToPourIn(container: Container) = if (container is Tank) {

0 commit comments

Comments
 (0)