0

What's wrong in this

abstract class Component(width: Int, height: Int) { protected var width = width protected var height = height abstract fun show() } class Button(width: Int, height: Int): Component(width, height) { private var name: String = "Button" fun tap() { println(name + " was tapped") } override fun show(){ println("Showing a Button") } } class Image(width: Int, height: Int): Component(width, height) { fun draw() { println(width.toString()+"x"+height.toString()) } override fun show(){ println("Showing a Image") } } fun main(args: Array<String>) { val b1 = Button(200, 50) b1.tap() b1.show() val img = Image(300, 500) img.draw() img.show() }

1st Apr 2023, 12:42 PM
HARI HARA SUDHAN K V
HARI HARA SUDHAN K V - avatar
2 Réponses
+ 7
HARI HARA SUDHAN K V what's the issue the output is shown
1st Apr 2023, 2:12 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 6
What is wrong that you ask a question without mentioning the language you are using. I tested your code as Kotlin and it seems to work. What is it you are not happy about?
1st Apr 2023, 2:12 PM
Paul
Paul - avatar