Пример #1
0
        private void UpdateBetUI(Gambler gambler)
        {
            //Render the Gambler's name and show or hide the Bet and Clear Bet buttons

            lblSelectedGambler.Text = gambler.Name;
            if (gambler.MyBet == null)
            {
                btnBet.Enabled      = true;
                btnClearBet.Enabled = false;
            }
            else
            {
                btnBet.Enabled      = false;
                btnClearBet.Enabled = true;
            }
        }
Пример #2
0
        private void Bet(Gambler gambler, int betAmount, int chosenSquirrel)
        {
            //Places bet if the gambler has enough cash available

            if (gambler.PlaceBet(betAmount, chosenSquirrel))
            {
                btnBet.Enabled      = false;
                btnClearBet.Enabled = true;
            }
            else
            {
                btnBet.Enabled      = true;
                btnClearBet.Enabled = false;
                MessageBox.Show(gambler.Name + " does not have enough cash to make that bet!");
            }
        }
Пример #3
0
        Random randomizer    = new Random(); //Ensures all of the Squirrel objects share a Random object to avoid an issue where all of the squirrels generate the same sequence of random numbers
        //TODO Add tests to project

        public Form1()
        {
            InitializeComponent();

            //Instantiate Gambler objects and update their labels on the form to shower user their cash/bet info
            gamblers[0] = new Gambler()
            {
                Name = "Drey", MyBet = null, Cash = 50, MyLabel = lblBetsGambler1, MyRadioButton = rdoGambler1
            };
            gamblers[1] = new Gambler()
            {
                Name = "Megan", MyBet = null, Cash = 100, MyLabel = lblBetsGambler2, MyRadioButton = rdoGambler2
            };
            gamblers[2] = new Gambler()
            {
                Name = "Kat", MyBet = null, Cash = 125, MyLabel = lblBetsGambler3, MyRadioButton = rdoGambler3
            };

            //Instantiate Squirrel objects
            //Note: the specific values below for StartingPosition (19) and RacetrackLength (-91) provide a more visually appealing location of the squirrel image in the UI
            squirrels[0] = new Squirrel()
            {
                StartingPosition = 19, RacetrackLength = (pictureBoxRaceTrack.Width - 91), MyPictureBox = pictureBoxRacer1, Randomizer = randomizer
            };
            squirrels[1] = new Squirrel()
            {
                StartingPosition = 19, RacetrackLength = (pictureBoxRaceTrack.Width - 91), MyPictureBox = pictureBoxRacer2, Randomizer = randomizer
            };
            squirrels[2] = new Squirrel()
            {
                StartingPosition = 19, RacetrackLength = (pictureBoxRaceTrack.Width - 91), MyPictureBox = pictureBoxRacer3, Randomizer = randomizer
            };
            squirrels[3] = new Squirrel()
            {
                StartingPosition = 19, RacetrackLength = (pictureBoxRaceTrack.Width - 91), MyPictureBox = pictureBoxRacer4, Randomizer = randomizer
            };

            UpdateSquirrelAndGamblerUI();
        }