Gold Challenge

Mayors are people too. An instance of the Mayor type will naturally get nervous whenever its town loses some population due to a Zombie attack. Create a stored instance property on the Mayor type called anxietyLevel. It should be of type Int, and should start out with a default value of 0.

Increment the anxietyLevel property every time a Mayor instance is notified of a Zombie attack. Last, as a mayor will not want to outwardly display anxiety, mark this property as private. Verify that this property is not accessible in main.swift.

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.