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
EquilateralTriangleclass)Square (The
Squareclass)Regular hexagon (The
RegularHexagonclass)
Exercise 2: Create immutable versions of the previously created classes