With surprisingly little work, you can use objects to model complex behavior. In this chapter you will make a model of a snowball fight. Each player is an object, and the menu system is a third object. Figures 5.1, 5.2, and 5.3 illustrate the snowball fight in progress.
The design of the snowball fight is simple. Both the player and the opponent are custom classes that have a lot in common. They have three properties: name, snowballs, and strength. Each player starts with three snowballs and, to win, has to make more during the fight. Each player also begins with three lives. When a player has been hit three times, that player loses the fight. The computer opponent is like the human player but has features that enable it to automatically play against the user.
18.188.154.252