Exercises

Create operator functions to allow us to determine whether two DomesticMammal instances are equal or not with the == and != operators. We will consider the instances to be equal when their age, name, and favoriteToy properties have the same value.

Create the following three new subclasses of the TerrierDog class:

  • AiredaleTerrier: This is an Airedale Terrier breed
  • BullTerrier: This is a Bull Terrier breed
  • CairnTerrier: This is a Cairn Terrier breed

Add the necessary code in these classes to print the text that represents the children in a different way than we did for the SmoothFoxTerrier class. Test the results by creating an instance of each of these classes and calling the printChildren method.

Get Swift 3 ObjectOriented Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.