Design

Bet associates an amount and an Outcome. In a future round of design, we can also associate a it with a Player.

Fields

  • int amountBet ;

    The amount of the bet.

  • Outcome outcome ;

    The outcome on which the bet is placed.

Constructors

  • Bet(int amount,
        Outcome outcome);

    Initialize the instance variables of this bet.

    For these first exercises, we'll omit the player. We'll come back to this class when necessary, and add that capability back in to this class.

Methods

  • int winAmount();

    Uses the Outcome's winAmount to compute the amount won, given the amount of this bet. Note that the amount bet must also be added in. A 1:1 outcome (e.g. a bet on Red) pays the amount bet plus the amount won.

  • int loseAmount();

    Returns the amount bet as the amount lost. This is the cost of placing the bet.

  • Java: public String toString();

    Python: def __str__(self):

    Returns a string representation of this bet. Note that this method will delegate the real work to the toString (or __str__) method of the Outcome (and the Player, when that is added).