Write a class Person that has an age property of type Int and an observable property isAdult of Boolean type that is updated whenever the value of the age property changes. The value of the isAdult property should be true if the person’s age is 18 or older and false otherwise.
Computer scienceProgramming languagesKotlinObject-oriented programmingObject-oriented programming features
Standard delegates
Adulthood
Report a typo
Sample Input 1:
13Sample Output 1:
falseWrite a program in Kotlin
import kotlin.properties.Delegates
class Person {
// Declare here the delegated property: age
// Do not change the declaration of the property: isAdult
var isAdult: Boolean = false
private set
}
___
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.