Table of Contents
In addition to defining the fundamental
Outcome on which all gambling is based, this
chapter provides a sidebar discussion on the notion of object identity
and object equality. This is important because we will be dealing with a
number of individual Outcome objects, and we need
to be sure we can test for equality of two
different objects. This is different from the test for
identity which asks if we have two references to
the same object.
The first class we will tackle is a small class that encapsulates each outcome. This class will contain the name of the outcome as a String, and the odds that are paid as an integer. We will use these objects when placing a bet and also when defining the Roulette wheel.
There will be several hundred instances of this class on a given
Roulette table. The bins on the wheel, similarly, collect various
Outcomes together. The minimum set of
Outcome instances we will need are the 38
numbers, Red and Black. The other instances add details to our
simulation.
In Roulette, the amount won is a simple multiplication of the
amount bet and the odds. In other games, however, there may be a more
complex calculation because the house keeps 5% of the winnings, called
the “rake”. While it is not part of Roulette, it is good
to have our Outcome class designed to cope with
these more complex payout rules.
Also, we know that other casino games, like Craps, are stateful.
An Outcome may change the game state. We can
foresee reworking this class to add in the necessary features to
change the state of the game.
While we are also aware that some odds are not stated as x:1, we won't include these other kinds of odds in this initial design. Since all Roulette odds are x:1, we'll simply assume that the denominator is always 1. We can forsee reworking this class to handle more complex odds, but we don't need to handle the other cases yet.