+ 1

Kotlin practice 32.2 Abstract classes

Can anyone help me with this question, please and thank you. You decide to make the Component class abstract, since you are not going to create objects of that type. You also add a show() function to it that the derived classes need to override. For a Button, the show() function should output: "Showing a Button", while for an Image it should output: "Showing an Image". Implement the required show() function to generate the expected output. // my code https://code.sololearn.com/cgGM09i5ZZ4l/?ref=app

2nd Oct 2022, 12:20 PM
Brent Tyson
Brent Tyson - avatar
6 Answers
+ 4
You'll probably kick yourself. I think you have too many printed lines. Also, you need to match the expected output exactly. You don't have the same capital letters, and you have a space at the end of your button line. So, not: println("Showing a button ") println("Showing an image") But: println("Showing a Button") println("Showing an Image")
2nd Oct 2022, 2:46 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
Hi Brent, you have linked the task, not your code (unfortunately, it's not so straightforward). To link your code, you need to copy your attempt from the task, go to the create tab (the code playground), start a new code, paste your attempt there and then you can attach it here.
2nd Oct 2022, 12:22 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Ausgrindtube i definietly kicked myself anddd with a face palm too. Thank you for the help Lol
2nd Oct 2022, 11:00 PM
Brent Tyson
Brent Tyson - avatar
+ 1
I've been there for sure. Coding is sometimes brutally exact! On the plus side, it's what removes human error due to our lazy ape brains. Happy learning and coding!
3rd Oct 2022, 7:36 AM
Ausgrindtube
Ausgrindtube - avatar
0
Ausgrindtube thank you. Will do
2nd Oct 2022, 1:42 PM
Brent Tyson
Brent Tyson - avatar
0
Ausgrindtube its edited and reposted now. Thanks again for the tutorial
2nd Oct 2022, 1:48 PM
Brent Tyson
Brent Tyson - avatar