Python Design

Bin contains a collection of Outcomes which reflect the winning bets that are paid for a particular bin on a Roulette wheel. In Roulette, each spin of the wheel has a number of Outcomes. Example: A spin of 1, selects the “1” bin with the following winning Outcomes: “1”, “Red”, “Odd”, “Low”, “Column 1”, “Dozen 1-12”, “Split 1-2”, “Split 1-4”, “Street 1-2-3”, “Corner 1-2-4-5”, “Five Bet”, “Line 1-2-3-4-5-6”, “00-0-1-2-3”, “Dozen 1”, “Low” and “Column 1”. These are collected into a single Bin.

Fields

  • outcomes = () 

    Holds the connection of individual Outcomes.

Constructors

Python programmers should provide an initializer that uses the * modifier so that all of the individual arguments appear as a single list within the initializer.

  • def __init__(self, *outcomes):

This constructor can be used as follows.

Example 5.2. Python Bin Construction

    five= Outcome( "00-0-1-2-3", 6 )
    zero= Bin( Outcome("0",35), five ) 1
    zerozero= Bin( Outcome("00",35), five ) 2
1

This creates zero Bin, which is based on references to two objects: the “0Outcome and the “00-0-1-2-3Outcome.

2

This creates zerozero, which is based on references to two objects: the “00Outcome and the “00-0-1-2-3Outcome.

Methods

  • def  add(self, outcome):

    Adds an Outcome to this Bin. This can be used by a builder to construct all of the bets in this Bin. Since this class is really just a façade over the underlying collection object, this method can simply delegate the real work to the underlying collection. Note that a tuple is immutable; unlike a list it does not have an append method. Instead, a tuple is constructed by using the “+” operator which creates a new tuple from two input tuples.

    Example 5.3. Python Appending Outcomes to A Tuple

        self.outcomes = self.outcomes + outcome
        
  • def __str__(self):

    An easy-to-read String output method is also very handy. This should return a String representation of the list of Outcomes in this Bin. A handy technique for displaying collections is the following. This maps the str function to each element of self.outcomes, then joins the resulting string with “,” separators.

    Example 5.4. Python String Conversion of a Tuple of Outcomes

        def __str__( self ):
            return ', '.join( map(str,self.outcomes) )