Bronze Challenge

Sometimes you write code that looks and feels right at the time, but in using it later find that something is not quite right. This is the case with the extension you used to make Car conform to VehicleType.

When you made Car conform to the VehicleType protocol, you added a numberOfDoors computed property that always returns 4. This effectively makes numberOfDoors a constant on Car. As a consequence, the if/else condition in kind will always return .Sedan. There is no other possibility due to how Car conforms to VehicleType.

Refactor Car to have a constant stored property named numberOfDoors. Note: this change will mean that you need to make other changes. Use the new compiler errors to guide your solution.

Get Swift Programming: The Big Nerd Ranch Guide 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.