object Threshold {
var value : Int = 0
fun increment() {
value++
}
fun isAboveThreshold(limit: Int) : Boolean {
if (value > limit)
return false
else
return true
}
}
fun main(args: Array<String>) {
val thresholdLimit = 5
for( value in 0..thresholdLimit + 1) {
Threshold.increment()
// Check whether the threshold is above the limit
println("Is above the limit: ${Threshold.isAboveThreshold(value)}")
}
}
I’m having a problem getting this code to work. It should return true when a value is above a certain limit. Please could you help.