A class which assists LotteryAccount with the selection of lucky accounts. Encapsulates a secret winning number and the amount won. A singleton class. More...
Public Member Functions | |
bool | WinningNumber (int n) |
Return if n is equal to the winning number. | |
decimal | AmountWon (int luckyNumber) |
Return the encapsulated amount won if luckyNumber is the winning number. | |
Static Public Member Functions | |
static Lottery | Instance (int difficulty) |
Returns the unique instance of this class. | |
Properties | |
int | DrawLotteryNumber [get] |
Draw and return a lottery number | |
Private Member Functions | |
Lottery (int difficulty) | |
Private Attributes | |
int | difficulty |
readonly int | winningNumber |
readonly decimal | amountWon |
Static Private Attributes | |
static Random | rdm = new Random(unchecked((int)DateTime.Now.Ticks)) |
static Lottery | uniqueInstance = null |
A class which assists LotteryAccount with the selection of lucky accounts. Encapsulates a secret winning number and the amount won. A singleton class.
Definition at line 6 of file lottery.cs.
Lottery.Lottery | ( | int | difficulty | ) | [private] |
Definition at line 15 of file lottery.cs.
References amountWon, rdm, and winningNumber.
Referenced by Instance().
decimal Lottery.AmountWon | ( | int | luckyNumber | ) |
Return the encapsulated amount won if luckyNumber is the winning number.
luckyNumber | Some integer number |
Definition at line 44 of file lottery.cs.
References amountWon, and WinningNumber().
Referenced by LotteryAccount.AddInterests().
static Lottery Lottery.Instance | ( | int | difficulty | ) | [static] |
Returns the unique instance of this class.
difficulty | A measure of the difficulty of winning. |
Definition at line 23 of file lottery.cs.
References Lottery(), and uniqueInstance.
bool Lottery.WinningNumber | ( | int | n | ) |
Return if n is equal to the winning number.
Definition at line 35 of file lottery.cs.
References winningNumber.
Referenced by AmountWon().
readonly decimal Lottery.amountWon [private] |
Definition at line 12 of file lottery.cs.
Referenced by AmountWon(), and Lottery().
int Lottery.difficulty [private] |
Definition at line 10 of file lottery.cs.
Random Lottery.rdm = new Random(unchecked((int)DateTime.Now.Ticks)) [static, private] |
Definition at line 8 of file lottery.cs.
Referenced by Lottery().
Lottery Lottery.uniqueInstance = null [static, private] |
Definition at line 13 of file lottery.cs.
Referenced by Instance().
readonly int Lottery.winningNumber [private] |
Definition at line 11 of file lottery.cs.
Referenced by Lottery(), and WinningNumber().
int Lottery.DrawLotteryNumber [get] |
Draw and return a lottery number
Definition at line 30 of file lottery.cs.
Referenced by LotteryAccount.AddInterests().