Building Skills in Object-Oriented Design¶

Step-by-Step Construction of A Complete Application

Roulette¶

This part describes the game of Roulette. Roulette is the game with the big wheel. They spin the wheel, toss in a marble and wait for the wheel to stop spinning.

Roulette is – essentially – a stateless game with numerous bets and a very simple process for game play.

The chapters of this part present the details on the game, an overview of the solution, and a series of sixteen exercises to build a complete simulation of the game, plus a variety of betting strategies. Each exercise chapter builds at least one class, plus unit tests; in some cases, this includes rework of previous deliverables.

Craps¶

This part describes parts of the more complex game of Craps. Craps is played with dice. A player throws the dice; sometimes it’s an immediate win (or loss). Other times, the number on the dice become the “point”, and you contine throwing dice until you make your point or crap out.

Craps is a game with two states and a number of state-change rules. It has a variety betting alternatives, some of which are quite complex.

The chapters of this part presents the details on the game, an overview of the solution, and a series of eleven exercises to build a complete simulation of the game, with a variety of betting strategies. The exercises in this part are more advanced; unlike Roulette, we will often combine several classes into a single batch of deliverables.

There are several examples of rework in this part, some of them quite extensive. This kind of rework reflects three more advanced scenarios: refactoring to generalize and add features, renaming to rationalize the architecture, and refactoring to extract features. Each of these is the result of learning; they are design issues that can’t easily be located or explained in advance.

Blackjack¶

This part describes the more complex game of Blackjack. Both the player and the dealer are trying to build a hand that totals 21 points without going over. The hand closest to 21 wins.

This game has a number of states and a number of complex state-change rules. It has very few different kinds of bets, but moderately complex rules for game play. However, it does have the most sophisticated playing strategy, since the player has a number of choices to make.

The chapters of this part presents the details on the game, an overview of the solution, and a series of six relatively complex exercises to build a complete simulation of the game. In the case of Blackjack, we have to create a design that allows for considerable variation in the rules of the game as well as variation in the player’s betting strategies.

Fit and Finish¶

A finished application includes more than just a working program. There are two additional questions.

• How do you know it works? That is, do you have any tests that demonstrate that it works correctly?

We address this by creating unit tests.

• How is it designed?

We address this by creating documentation within the program’s source files. This documentation can be extracted to create a tidy, complete reference for all the classes and functions within our application.