Exercises

Create the following protocols to solve the problem explained in Chapter 1, Objects from the Real-World to the Playground:

  • AbstractShape
  • AbstractRegularPolygon
  • AbstractEllipse
  • AbstractRectangle
  • AbstractCircle

After you create the protocols, create classes that implement them based on the specifications explained in Chapter 1, Objects from the Real-World to the Playground.

The following table summarizes the list of protocols to which each of the classes you must create will conform:

Class name

Conforms to the following protocol(s)

Shape

AbstractShape

Rectangle

AbstractRectangle and AbstractShape

RegularPolygon

AbstractRegularPolygon and AbstractShape

Ellipse

AbstractEllipse and AbstractShape

Circle

AbstractCircle ...

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.