private void PrepareHoundsAndGuys() { GreyhoundArray[0] = new Greyhound(Dog1PictureBox, Dog1PictureBox.Left, TrackPictureBox.Width - Dog1PictureBox.Width, MyRandomizer); GreyhoundArray[1] = new Greyhound(Dog2PictureBox, Dog2PictureBox.Left, TrackPictureBox.Width - Dog2PictureBox.Width, MyRandomizer); GreyhoundArray[2] = new Greyhound(Dog3PictureBox, Dog3PictureBox.Left, TrackPictureBox.Width - Dog3PictureBox.Width, MyRandomizer); GreyhoundArray[3] = new Greyhound(Dog4PictureBox, Dog4PictureBox.Left, TrackPictureBox.Width - Dog4PictureBox.Width, MyRandomizer); GuyArray[0] = new Guy("Joe", 50, joeRadioButton, joeBetLabel); GuyArray[1] = new Guy("Bob", 75, bobRadioButton, bobBetLabel); GuyArray[2] = new Guy("Al", 45, alRadioButton, alBetLabel); foreach (Guy guy in GuyArray) { guy.UpdateLabels(); } }
public MainWindow() { InitializeComponent(); MyRandomizer = new Random(); minimumBetLabel.Content = "Minimum bet: " + bucksUpDownControl.Minimum + " bucks"; dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += dispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1); GreyhoundArray[0] = new Greyhound() { MyImage = imageDog1, StartingPosition = (int)imageDog1.Margin.Left, RacetrackLenght = (int)imageRacetrack.Width - (int)imageDog1.Width, Randomizer = MyRandomizer }; GreyhoundArray[1] = new Greyhound() { MyImage = imageDog2, StartingPosition = (int)imageDog2.Margin.Left, RacetrackLenght = (int)imageRacetrack.Width - (int)imageDog2.Width, Randomizer = MyRandomizer }; GreyhoundArray[2] = new Greyhound() { MyImage = imageDog3, StartingPosition = (int)imageDog3.Margin.Left, RacetrackLenght = (int)imageRacetrack.Width - (int)imageDog3.Width, Randomizer = MyRandomizer }; GreyhoundArray[3] = new Greyhound() { MyImage = imageDog4, StartingPosition = (int)imageDog4.Margin.Left, RacetrackLenght = (int)imageRacetrack.Width - (int)imageDog4.Width, Randomizer = MyRandomizer }; GuyArray[0] = new Guy() { Name = "Joe", Cash = 50, MyRadioButton = joeRadioButton, MyLabel = joeBetLabel, }; GuyArray[1] = new Guy() { Name = "Bob", Cash = 75, MyRadioButton = bobRadioButton, MyLabel = bobBetLabel, }; GuyArray[2] = new Guy() { Name = "Al", Cash = 45, MyRadioButton = alRadioButton, MyLabel = alBetLabel, }; foreach (Guy guy in GuyArray) { guy.UpdateLabels(); } }
bool betPlaced = false; // to verify if at least one guy has placed a bet public Form1() { InitializeComponent(); minimumBetLabel.Text = "Minimum bet: " + betNumericUpDown.Minimum + " bucks"; nameLabel.Text = ""; // Dog 1 initialization GreyhoundArray[0] = new Greyhound() { StartingPosition = greyhound1.Left, MyPictureBox = greyhound1, RacetrackLength = raceTrackPictureBox.Width - greyhound1.Width, Randomizer = MyRandomizer }; // Dog 2 initialization GreyhoundArray[1] = new Greyhound() { StartingPosition = greyhound2.Left, MyPictureBox = greyhound2, RacetrackLength = raceTrackPictureBox.Width - greyhound2.Width, Randomizer = MyRandomizer }; // Dog 3 initialization GreyhoundArray[2] = new Greyhound() { StartingPosition = greyhound3.Left, MyPictureBox = greyhound3, RacetrackLength = raceTrackPictureBox.Width - greyhound3.Width, Randomizer = MyRandomizer }; // Dog 4 initialization GreyhoundArray[3] = new Greyhound() { StartingPosition = greyhound4.Left, MyPictureBox = greyhound4, RacetrackLength = raceTrackPictureBox.Width - greyhound4.Width, Randomizer = MyRandomizer }; // Guy 1 (Joe) initialization GuyArray[0] = new Guy() { Name = "Joe", Cash = 50, MyBet = null, MyLabel = joeBetLabel, MyRadioButton = joeRadioButton }; // Guy 2 (Bob) initialization GuyArray[1] = new Guy() { Name = "Bob", Cash = 75, MyBet = null, MyLabel = bobBetLabel, MyRadioButton = bobRadioButton }; // Guy 3 (Al) initialization GuyArray[2] = new Guy() { Name = "Al", Cash = 45, MyBet = null, MyLabel = alBetLabel, MyRadioButton = alRadioButton }; // clear each guy's bet to zero and update their label for (int i = 0; i < GuyArray.Length; ++i) { GuyArray[i].ClearBet(); GuyArray[i].UpdateLabels(); } }
public Form1() { InitializeComponent(); joe.MyLabel = joeBetLabel; joe.MyRadioButton = joeRadioButton; bob.MyLabel = bobBetLabel; bob.MyRadioButton = bobRadioButton; al.MyLabel = alBetLabel; al.MyRadioButton = alRadioButton; minimumBetLabel.Text = "Minimum bet: " + minBet + " bucks"; joeBetLabel.Text = "Joe hasn't placed a bet yet"; bobBetLabel.Text = "Bob hasn't placed a bet yet"; alBetLabel.Text = "Al hasn't placed a bet yet"; joeRadioButton.Text = "Joe has " + joe.Cash + " bucks"; bobRadioButton.Text = "Bob has " + bob.Cash + " bucks"; alRadioButton.Text = "Al has " + al.Cash + " bucks"; nameLabel.Text = "Joe"; domainUpDown1.Items.Add("Momma's Boy"); domainUpDown1.Items.Add("Seattle Slew"); domainUpDown1.Items.Add("Seabiscuit"); domainUpDown1.Items.Add("Secretariat"); domainUpDown1.SelectedIndex = 0; Random MyRandomizer = new Random(); GreyhoundArray[0] = new Greyhound() { Name = "Momma's Boy", MyPictureBox = pictureBox1, StartingPosition = pictureBox1.Left, RacetrackLength = raceTrackPictureBox.Width - pictureBox1.Width, Randomizer = MyRandomizer }; GreyhoundArray[1] = new Greyhound() { Name = "Seattle Slew", MyPictureBox = pictureBox2, StartingPosition = pictureBox2.Left, RacetrackLength = raceTrackPictureBox.Width - pictureBox2.Width, Randomizer = MyRandomizer }; GreyhoundArray[2] = new Greyhound() { Name = "Seabiscuit", MyPictureBox = pictureBox3, StartingPosition = pictureBox3.Left, RacetrackLength = raceTrackPictureBox.Width - pictureBox3.Width, Randomizer = MyRandomizer }; GreyhoundArray[3] = new Greyhound() { Name = "Secretariat", MyPictureBox = pictureBox4, StartingPosition = pictureBox4.Left, RacetrackLength = raceTrackPictureBox.Width - pictureBox4.Width, Randomizer = MyRandomizer }; }