Course of Raku / Addendum 🆕 / Types and text machines / Objects and classes / Exercises

Animals that speak

Problem

Make an Animal base class with a name and a greet method that says what the animal says. Subclasses Dog and Cat each define their own sound. Have a Dog named Rex and a Cat named Tom greet.

Example

The program prints:

Rex says Woof
Tom says Meow

Solution

See the solution

Course navigation

Solution: Adding vectors   |   Solution: Animals that speak