Pumpkin and candle

Report a typo

We have two classes: Pumpkin and Candle. We want them to behave the following way: if the pumpkin is for Halloween, then it should have a candle inside.

In the outer class Pumpkin create a function fun addCandle(). If the isForHalloween member is true, then create a Candle and call its function fun burning(). Otherwise, print the message We don't need a candle.

Write a program in Kotlin
class Pumpkin(val type: String, val isForHalloween: Boolean) {

// create function addCandle()

inner class Candle {
fun burning() {
println("The candle is burning inside this spooky $type pumpkin! Boooooo!")
}
}
}
___

Create a free account to access the full topic