Exercises
Now that you understand instance properties, type properties, and methods, it is time to spend some time in the Playground, the Swift REPL, or the Sandbox, creating new classes and instances:
- Exercise 1: Create mutable versions of the following three classes that we analyzed in Chapter 1, Objects from the Real-World to the Playground:
- Equilateral triangle (The
EquilateralTriangle
class) - Square (The
Square
class) - Regular hexagon (The
RegularHexagon
class)
- Equilateral triangle (The
- Exercise 2: Create immutable versions of the previously created classes
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.