Course of Raku / Objects, I/O, and exceptions / Classes and objects / Inheritance / Exercises
A shape and a square
Problem
Define a base class Shape with a method
name that returns 'shape', and a method
describe that returns the string
I am a <name> (using its own name).
Then define a class Square that inherits from
Shape and overrides name to return
'square'.
Print the description of a Square.
Example
The program prints:
I am a squareSolution
Course navigation
← Solution: Employees and roles | Solution: A shape and a square →