Exercises
Here is a list of a few things you could do to further improve the GUI application. With one exception, the solutions are not provided for these exercises.
Put the
Model
,View
and,Controller
classes in their own modules!Use the publish-subscribe API for communication from
View
toController
. You can refer to the filehutgame_mvc_pubsub.py
for a solution.Add more widgets such as a menu bar and buttons. Implement the Restart Game button. When clicked, the game should restart. Do the following when this button is clicked:
Randomly distribute the occupants again by calling
occupy_huts()
.Clear the state of the radio buttons. All the buttons should be deselected.
Add exception handling to the application.
Try to generalize the
View.add_callbacks
method so that it can be used to set more callback functions.