Don't get in, it's dangerous

Report a typo

Fix the boiler class so that we can't access the degradation level and this field was used to visualize the status.

val boiler = Boiler(56.10, 2)

boiler.degradationLevel += 1 // Should not compile
boiler.temperature += 20.9 // OK

println(boiler.status)

Sample Input 1:

56.1 2

Sample Output 1:

Temperature: 56.1. Requires verification: false
Write a program in Scala 3
class Boiler(var temperature: Double, var degradationLevel: Int):
def status: String = s"Temperature: $temperature. Requires verification: ${degradationLevel > 10}"
___

Create a free account to access the full topic