Beispiel #1
0
        private void btnReset_Click(object sender, EventArgs e)
        {
            foreach (Truck truck in TruckArray)
            {
                truck.TrucksStartingPosition();
            }
            if (simranBetLabel.Text == "Destroyed" && rajinderBetLabel.Text == "Destroyed" && sandeepBetLabel.Text == "Destroyed")
            {
                RaceTrackInitialization();

                PuntersArray[0] = new Gambler()        //This array for the punter class Initialization
                {
                    ClientName    = "Simran",          //Here i define the name of client
                    TruckBet      = null,              //Set the bet null
                    Cashes        = 70,                //set cash 70
                    MyRadioButton = radioButtonSimran, //assign radio buuton
                    MyLabel       = simranBetLabel     //assign the labe to punter class
                };

                PuntersArray[1] = new Gambler()
                {
                    ClientName    = "Rajinder",
                    TruckBet      = null,
                    Cashes        = 95,
                    MyRadioButton = radioButtonRajinder,
                    MyLabel       = rajinderBetLabel
                };

                PuntersArray[2] = new Gambler()
                {
                    ClientName    = "Sandeep",
                    TruckBet      = null,
                    Cashes        = 65,
                    MyRadioButton = radioButtonSandeep,
                    MyLabel       = sandeepBetLabel
                };

                foreach (Gambler punter in PuntersArray)
                {
                    punter.UpdateLabels();
                }
                simranBetLabel.ForeColor    = System.Drawing.Color.Black;
                rajinderBetLabel.ForeColor  = System.Drawing.Color.Black;
                sandeepBetLabel.ForeColor   = System.Drawing.Color.Black;
                radioButtonSimran.Enabled   = true;
                radioButtonRajinder.Enabled = true;
                radioButtonSandeep.Enabled  = true;
                numericUpDownForBet.Value   = 1;
                numericUpDownNumber.Value   = 1;
            }
        }
Beispiel #2
0
        private void RaceTrackInitialization()//this is the initialization of race track here i assign the initial values of the variables
        {
            radioButtonSimran.Checked = true;
            minimumBetLabel.Text      = "Minimum Bet : " + numericUpDownNumber.Minimum.ToString() + " dollars";//Setting the minimum value of numeric updownnumber
            TruckArray[0]             = new Truck()
            {
                TruckPictureBox       = truck1,                            //initialize picture 1 to first array
                TruckBeginingPosition = truck1.Top,                        //initialize to starting position
                TruckTrackLength      = truckTrack.Height - truck1.Height, //initialize track length
                RandomNumber          = RandomNumbers                      //initialize random numbers
            };

            TruckArray[1] = new Truck()//this is for second array of truck class initialization
            {
                TruckPictureBox       = truck2,
                TruckBeginingPosition = truck2.Top,
                TruckTrackLength      = truckTrack.Height - truck2.Height,
                RandomNumber          = RandomNumbers
            };

            TruckArray[2] = new Truck()
            {
                TruckPictureBox       = truck3,
                TruckBeginingPosition = truck3.Top,
                TruckTrackLength      = truckTrack.Height - truck3.Height,
                RandomNumber          = RandomNumbers
            };

            TruckArray[3] = new Truck()
            {
                TruckPictureBox       = truck4,
                TruckBeginingPosition = truck4.Top,
                TruckTrackLength      = truckTrack.Height - truck4.Height,
                RandomNumber          = RandomNumbers
            };


            PuntersArray[0] = new Gambler()        //This array for the punter class Initialization
            {
                ClientName    = "Simran",          //Here i define the name of client
                TruckBet      = null,              //Set the bet null
                Cashes        = 70,                //set cash 70
                MyRadioButton = radioButtonSimran, //assign radio buuton
                MyLabel       = simranBetLabel     //assign the labe to punter class
            };

            PuntersArray[1] = new Gambler()
            {
                ClientName    = "Rajinder",
                TruckBet      = null,
                Cashes        = 95,
                MyRadioButton = radioButtonRajinder,
                MyLabel       = rajinderBetLabel
            };

            PuntersArray[2] = new Gambler()
            {
                ClientName    = "Sandeep",
                TruckBet      = null,
                Cashes        = 65,
                MyRadioButton = radioButtonSandeep,
                MyLabel       = sandeepBetLabel
            };

            for (int i = 0; i <= 2; i++)
            {
                PuntersArray[i].UpdateLabels();
                PuntersArray[i].TruckBet = new Bettor();
            }
        }