The implementations of vehicle types were slightly different between the object-oriented example and the protocol-oriented example; however, the difference is still pretty significant. We will look at the differences between these two examples, but first, let's take a look at the code again to remind us how we implemented the vehicle types. We will look at how we implemented the Tank type in the object-oriented example first:
class Tank: Vehicle {
override init() {
super.init() vehicleTypes = [.land]
vehicleAttackTypes = [.land]
vehicleMovementTypes = [.land]
landAttackRange = 5
hitPoints = 68
}
override func doLandAttack() {
print("Tank Attack")
}
override func doLandMovement() {
print("Tank Move")
}
}
This class is a subclass of the Vehicle superclass...