private void Btn_Powerball_Click(object sender, EventArgs e) { newTicket = new powerball(random); winningTicket = new powerball(random); Bets <powerball> boughtTicket = new Bets <powerball>(); boughtTicket.WagerAmount = 2; boughtTicket.Mine = newTicket; boughtTicket.Theirs = winningTicket; int result = boughtTicket.Do_Powerball_Bet(); if (result > 0) { this.Lbl_pbWinner.Text = "You win:"; this.powerballWinnings.ForeColor = System.Drawing.Color.White; this.powerballWinnings.Text = "+ $"; this.powerballWinnings.Text = result.ToString(); } else { this.Lbl_pbWinner.Text = "You lose: "; this.powerballWinnings.ForeColor = System.Drawing.Color.Red; this.powerballWinnings.Text = "$"; this.powerballWinnings.Text += result.ToString(); } setEarnings(result); }
private void btn_race_Click(object sender, EventArgs e) { int raceResult = 0, result = 60, maxSpeed = 0; string fastestHorse = ""; myHorse.randomizeSpeed(); for (int i = 0; i < 4; i++) { opponents[i].randomizeSpeed(); } Bets <Horse> horseRace = new Bets <Horse>(); horseRace.WagerAmount = 30; horseRace.Mine = myHorse; for (int i = 0; i < 4; i++) { horseRace.Theirs = opponents[i]; raceResult = horseRace.DoBet(); if (raceResult < result) { result = raceResult; } } if (myHorse.getSpeed() > maxSpeed) { maxSpeed = myHorse.getSpeed(); fastestHorse = myHorse.getName(); } for (int i = 0; i < 4; i++) { if (opponents[i].getSpeed() > maxSpeed) { maxSpeed = opponents[i].getSpeed(); fastestHorse = opponents[i].getName(); } } if (result > 0) { this.lbl_horseResult.Text = "You win: "; this.horseWinnings.ForeColor = System.Drawing.Color.White; this.horseWinnings.Text = "+ $"; this.horseWinnings.Text += result.ToString(); } else { this.lbl_horseResult.Text = "You lose: "; this.horseWinnings.ForeColor = System.Drawing.Color.Red; this.horseWinnings.Text = "$"; this.horseWinnings.Text += result.ToString(); } this.winningHorseData.Text = fastestHorse; setEarnings(result); this.btn_race.Enabled = false; this.horse1.Enabled = false; this.horse2.Enabled = false; this.horse3.Enabled = false; this.horse4.Enabled = false; this.horse5.Enabled = false; this.btn_play_horse.Enabled = true; }