Beispiel #1
0
        private void btnReset_Click(object sender, EventArgs e)
        {
            foreach (Cars car in CarArray)
            {
                car.CarsStartingPosition();
            }
            if (joeBetLabel.Text == "BUSTED" && bobBetLabel.Text == "BUSTED" && alBetLabel.Text == "BUSTED")
            {
                settingTheRaceTrack();
                //this part is for assigning the values which is created in punter class
                PuntersArray[0] = new Punter()
                {
                    PunterName    = "Joe",
                    MyBetForCar   = null,
                    Cash          = 50,
                    MyRadioButton = joeRadioButton,
                    MyLabel       = joeBetLabel
                };

                PuntersArray[1] = new Punter()
                {
                    PunterName    = "Bob",
                    MyBetForCar   = null,
                    Cash          = 75,
                    MyRadioButton = bobRadioButton,
                    MyLabel       = bobBetLabel
                };

                PuntersArray[2] = new Punter()
                {
                    PunterName    = "Al",
                    MyBetForCar   = null,
                    Cash          = 45,
                    MyRadioButton = alRadioButton,
                    MyLabel       = alBetLabel
                };

                foreach (Punter punter in PuntersArray)
                {
                    punter.UpdatingLabels();//using the foreach loop for assigning the values of labels for bet
                }
                joeBetLabel.ForeColor  = System.Drawing.Color.Black;
                bobBetLabel.ForeColor  = System.Drawing.Color.Black;
                alBetLabel.ForeColor   = System.Drawing.Color.Black;
                joeRadioButton.Enabled = true;
                bobRadioButton.Enabled = true;
                alRadioButton.Enabled  = true;
                numericUpDown1.Value   = 1;
                numericUpDown2.Value   = 1;
            }
        }
Beispiel #2
0
        private void settingTheRaceTrack()//this funtion is for setting the race track
        {
            joeRadioButton.Checked = true;
            // initialize minimum bet label
            minimumBetLabel.Text = "Minimum Bet : " + numericUpDown1.Minimum.ToString() + " dollars";

            // initialize all 4 elements of the CarArray
            sukhmanCarArray[0] = new Cars()
            {
                MyPictureBox        = Car1,
                CarStartingPosition = Car1.Left,
                TrackLength         = pictureBox1.Width - Car1.Width,
                Randomizer          = rnd
            };

            sukhmanCarArray[1] = new Cars()
            {
                MyPictureBox        = Car2,
                CarStartingPosition = Car2.Left,
                TrackLength         = pictureBox1.Width - Car2.Width,
                Randomizer          = rnd
            };

            sukhmanCarArray[2] = new Cars()
            {
                MyPictureBox        = Car3,
                CarStartingPosition = Car3.Left,
                TrackLength         = pictureBox1.Width - Car3.Width,
                Randomizer          = rnd
            };

            sukhmanCarArray[3] = new Cars()
            {
                MyPictureBox        = Car4,
                CarStartingPosition = Car4.Left,
                TrackLength         = pictureBox1.Width - Car4.Width,
                Randomizer          = rnd
            };

            //initialize all 3 elements of the GuysArray
            sukhmanPuntersArray[0] = new Punter()
            {
                PunterName    = "Sukhman",
                MyBetForCars  = null,
                Cashes        = 50,
                MyRadioButton = joeRadioButton,
                MyLabel       = joeBetLabel
            };

            sukhmanPuntersArray[1] = new Punter()
            {
                PunterName    = "Sid",
                MyBetForCars  = null,
                Cashes        = 75,
                MyRadioButton = bobRadioButton,
                MyLabel       = bobBetLabel
            };

            sukhmanPuntersArray[2] = new Punter()
            {
                PunterName    = "Ajay",
                MyBetForCars  = null,
                Cashes        = 45,
                MyRadioButton = alRadioButton,
                MyLabel       = alBetLabel
            };

            for (int i = 0; i <= 2; i++)
            {
                sukhmanPuntersArray[i].UpdatingLabels();
                sukhmanPuntersArray[i].MyBetForCars = new Bet();
            }
        }