Fridge

Report a typo

Assume there is the Fridge class. It contains the following member functions:

  • open(): Unit opens the fridge.
  • find(productName: String): Product returns a product by its name.
  • close(): Unit closes the fridge.

Implement Fridge.take(productName: String): Product. It opens the fridge, finds the product, closes the fridge and returns the found product.

Write a program in Kotlin
//Do not fix code below
class Fridge {
fun open() = println(1)
fun find(productName: String): Product {
println(productName)
return 4
}
fun close() = println(3)
}

//Write your code here
___

Create a free account to access the full topic