Bronze Challenge

There is currently a bug in the Zombie type. If an instance of Zombie terrorizes a town with a population of 0, then its population will decrement to -10. This result does not make sense. Fix this bug by changing the terrorizeTown() function on the Zombie type to only decrement the town’s population if its population is greater than 0. Also, make sure that the town’s population is set to 0 if the amount to decrement is greater than the current population.

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.