O'Reilly logo

Swift 3 ObjectOriented Programming - Second Edition by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required