Imagine you have a service which helps people to move from one place to another. You have boxes for packaging different types of furniture: ArmchairBox for an armchair, FridgeBox for a fridge, but it's not convenient because boxes differ only in volume. Create a universal class Box, which contains furniture of some type and the volume of a box. Add a primary constructor for initializing furniture and volume, which is Int. Complete the methods getBoxVolume() and getFurnitureFromBox() for getting both fields of Box.
Introduction to generic programming
Code to move
Report a typo
Write a program in Kotlin
// implement primary constructor and methods
class Box<T> {
fun getBoxVolume()
fun getFurnitureFromBox()
}
// Don't change classes below
class Fridge
class Armchair
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.