Silver Challenge
Make a new type called Mayor. It should be a struct. The Town type should have a property called mayor that holds an instance of the Mayor type.
Have your town inform the mayor every time the property for population changes.
If the town’s population decreases, have the instance of the Mayor log this statement to the console: "I'm deeply saddened to hear about this latest tragedy.
I promise that my office is looking into the nature of this rash of violence."
If the population increases, then the mayor should do nothing.
(Hint: You should define a new instance method on the Mayor type to complete this challenge.)
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