Course of Raku / Addendum 🆕 / Types and text machines / Objects and classes / Exercises
Shapes sharing a role
Problem
Define a Shape role that requires an area
method, then make Circle and Square classes
that do the role. Print the area of a circle of radius 2
and a square of side 3, each labelled with its class
name.
Example
The program prints:
Circle: 12.56636
Square: 9Solution
Course navigation
← Solution: A bank account | Solution: Shapes sharing a role →