Woof!

Report a typo

Write a class Labrador that inherits from a class Dog:

open class Dog(val name: String, val color: String, val weight: Int) {
    fun printInfo() {
        println("The dog's name is $name, his color is $color and his weight is $weight")
    }
}

The Dog class has one method called printInfo(), which prints The dog's name is $name, his color is $color and his weight is $weight.

Sample Input 1:

Pik
white
40

Sample Output 1:

The dog's name is Pik, his color is white and his weight is 40
Write a program in Kotlin
open class Dog(val name: String, val color: String, val weight: Int) {
fun printInfo() {
println("The dog's name is $name, his color is $color and his weight is $weight")
}
}
// do not change the code above
// write your code here
___

Create a free account to access the full topic