Init usage

Report a typo

There is a program that reads a number. If the number is less than -128, then the property time of a ByteTimer class must be -128. If it's greater than 127, then it must be 127, otherwise, it must be its raw value.

Fix the ByteTimer class.

Tip: Use an init block.

Sample Input 1:

-200

Sample Output 1:

-128
Write a program in Kotlin
fun main() {
val timerValue = readLine()!!.toInt()
val timer = ByteTimer(timerValue)
println(timer.time)
}

class ByteTimer(var time: Int) {}
___

Create a free account to access the full topic