O'Reilly logo

Swift Programming: The Big Nerd Ranch Guide by John Gallagher, Matthew Mathias

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required