Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
Create a SmartHome class that can control the temperature and lock status of a home. The class should have properties for the home's name, temperature, and lock status, and methods to adjust the temperature and toggle the lock. Fill in the blanks to complete the class definition.Computer scienceProgramming languagesKotlinObject-oriented programmingObject-oriented programming basic
Declaring classes
Home, sweet automated home
Report a typo
Fill in the gaps with the relevant elements
SmartHome( name: String, temperature: Int, var isLocked: Boolean) {
adjustTemperature(newTemp: Int) {
temperature = newTemp
("Temperature in $name set to $temperature°C")
}
fun toggleLock() {
isLocked = !isLocked
println("$name is now ${if (isLocked) "locked" else "unlocked"}")
}
}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.