Christmas tree

Report a typo

You have a class ChristmasTree and its inner class TreeTopper. Both classes have members named color.

In the class TreeTopper, create a function sparkle() that prints the message The sparkling <topper color> tree topper looks stunning on the <tree color> Christmas tree!

For a green Christmas tree with a silver tree topper, the output of the sparkle function should be:

The sparkling silver tree topper looks stunning on the green Christmas tree!

In the class ChristmasTree, сreate a function putTreeTopper() that takes one parameter color: String. In this function, you should create an instance of an inner class with the color parameter and then call the function sparkle of the instantiated TreeTopper.

Write a program in Kotlin
class ChristmasTree(var color: String) {

// create function putTreeTopper()

inner class TreeTopper(var color: String) {

// create function sparkle()
}
}
___

Create a free account to access the full topic