Using object-oriented design
Swift fully supports developing applications using object-oriented principles. When it was first released, it was primarily viewed as an object-oriented language, much like Java and C#.
In this section, we will design the vehicle types using an object-oriented approach and examine the advantages and disadvantages of this design.
Before looking at the code, let’s create a basic diagram to illustrate the vehicle class hierarchy and group related classes in our object-oriented design. With Swift being a single-inheritance language, each class can inherit from only one superclass. The root class in the hierarchy is the only class without a superclass.
Visualizing our class hierarchy
I typically begin with a simple diagram that outlines the classes without much detail. This allows me to visualize the class hierarchy. The following diagram shows the class hierarchy for our object-oriented design:

Figure 19.1: Vehicle class hierarchy...