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

Add the following operators to work with both MutableVector3D<T> and ImmutableVector3D<T>:

  • ==: This determines whether all the elements that compose a 3D vector (x, y, and z) are equal.
  • +: This sums each element that composes a 3D vector and saves the result in each element or in the new returned instance according to the class version (mutable or immutable). The new x must have the result of the left-hand side x + right-hand side x, the new y must be that of the left-hand side y + right-hand side y, and the new z must be that of the left-hand side z + right-hand side z.

In Chapter 4, Inheritance, Abstraction and Specialization, we created an Animal class and then defined specific operator functions to allow us to use operators with instances ...

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