Course of Raku / Objects, I/O, and exceptions / Classes and objects / Roles / Exercises
A named, aged pet
Problem
Define two roles:
Named, with a methodlabelthat returnsI am <name>;Aged, with a methodstatusthat returns<age> years.
Then define a class Pet that does both roles and has the
attributes name and age. Create a pet named
Rex aged 3, and print its label
and its status.
Example
The program prints:
I am Rex
3 years