public Form1() { InitializeComponent(); // get the position of the Race Track set starting point using the local variable of startposition int startPosition = pbHorse1.Right - track.Left; /*get the width of the of the reacetrack to get the ending point position of the track * for getting the winner with the help of racetrackLength */ int raceTrackLength = track.Size.Width; //pass the value to game class using the object objgame[0] = new Game() { objPictureBox = pbHorse1, RacetrackLength = raceTrackLength, Position = startPosition }; objgame[1] = new Game() { objPictureBox = pbHorse2, RacetrackLength = raceTrackLength, Position = startPosition }; objgame[2] = new Game() { objPictureBox = pbHorse3, RacetrackLength = raceTrackLength, Position = startPosition }; //pass the name of the players and money to recpectively buddies class objBuddies[0] = new Buddies("Harpreet", null, 50, chkHarpreet, lblHarpreet); objBuddies[1] = new Buddies("Joban", null, 50, chkJoban, lblJoban); objBuddies[2] = new Buddies("Happy", null, 50, chkHappy, lblHappy); // this foreach loop is used for printing the name of players on label using the object of Guy class with the help of object foreach (Buddies guy in objBuddies) { guy.UpdateLabels(); } }
//constructor method of the class so thus the local value can be pass to global variables public Winner(int Amount, int Horse, Buddies Bettor) { this.Amount = Amount; this.Horse = Horse; this.Bettor = Bettor; }