Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* INHERITANCE
- * Create sub class from main class (Inheritance)
- * Create object from made class
- * */
- open class oop_vehicle {
- var name: String? = null
- var color: String? = null
- var wheels: Int? = null
- constructor()
- // Constructor
- constructor(name: String, color: String, wheels: Int) : this() {
- this.color = color
- this.name = name
- this.wheels = wheels
- println("Object, wheels: " + this.wheels + " name: " + this.name + " color: " + this.color)
- }
- }
- // Inheritance ( : )
- class car() : oop_vehicle()
- fun main() {
- // Create object
- var sedan = oop_vehicle("bmw", "red", 4)
- // Create object from class: car
- var cars = car()
- cars.wheels = 8
- println("Wheels: ${cars.wheels}")
- }
Advertisement
Add Comment
Please, Sign In to add comment