You have a class called QuizBox, which stores items (item) of some type. Also, this class has a field isChanged of type Boolean, which shows if an instance of QuizBox was changed. By default, it equals false. Change the standard get and set methods for the field item. When the get() method is invoked, it should print "You asked for the item" and return the item. When set() is invoked, you should set a new value of item,change isChanged to true and print "You changed the item".
Introduction to generic programming
Get and set
Report a typo
Write a program in Kotlin
data class QuizBox<T>(val hiddenItem: T) {
var isChanged = false
var item: T = hiddenItem
// implement methods
get() {}
set(value) {}
}
___
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.