Pseudo-constructor

Report a typo

Suppose, you have this class:

class Point3D {
    var x: Int = 0
    var y: Int = 0
    var z: Int = 0
}

Write a function that receives the values x, y, z and returns an object of this class with these properties

Write a program in Kotlin
class Point3D {
var x: Int = 0
var y: Int = 0
var z: Int = 0
}

fun createPoint(x: Int, y: Int, z: Int): Point3D {
// provide implementation here
}
___

Create a free account to access the full topic