+ 1

Guys can someone notice the mistake that l made coz the code is outputting an error.(Kotlin inheritance)

open class Person(age:Int, name:String) init{ println("My name is $name") println("My age is $age") } class MathTeacher(age: Int, name: String ) :Person(age,name){ fun TeachMaths(){ println("I teach at Ntare School.") } } class Footballer(age: Int, name: String):Person(age,name){ fun Playfootball(){ println("I play for Machester United football club.") } } class Programmer(age: Int,name: String):Person(age,name){ fun Program(){ println("I program apps,games,websites and artificial intelligence.") } } fun main(args: Array<String>){ val t1=MathTeacher(44,"Robert") t1.MathTeacher() println() val f1=Footballer(33,"Halland") f1.Footballer() println() val p1=Programmer(16,"Morris") p1.Programmer() println() }

31st Aug 2022, 6:51 PM
Ayebazibwe Morris
Ayebazibwe Morris - avatar
1 Resposta
+ 2
You can LIMK YOUR CODE like this: Go to Code section, click +, select the programming language, insert your code, save. Come back to this thread, click +, Insert Code, sort for My Code Bits, select your code. This way, people can test your code and it is easier to read.
1st Sep 2022, 1:03 PM
Lisa
Lisa - avatar