Bronze Challenge
Sometimes you write code that looks and feels right at the time, but in using it later you find that something is not quite right.
This is the case with the extension you used to make Car conform to Vehicle.
When you made Car conform to the Vehicle 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 Vehicle.
Refactor Car to have a constant stored property named numberOfDoors. Note: This change will mean that you need to make other changes. Use the compiler errors to guide your solution.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access