public int CompareTo(object obj) { PowerBall other = obj as PowerBall; Array.Sort(this.Balls); Array.Sort(other.Balls); if (this.Balls == other.Balls && this.RedBall == other.RedBall) { WinType = 9; return(1); } else if (this.Balls == other.Balls) { WinType = 8; return(1); } else if (this.Balls[0] == other.Balls[0] && this.Balls[1] == other.Balls[1] && this.Balls[2] == other.Balls[2] && this.Balls[3] == other.Balls[3] && this.RedBall == other.RedBall) { WinType = 7; return(1); } else if (this.Balls[0] == other.Balls[0] && this.Balls[1] == other.Balls[1] && this.Balls[2] == other.Balls[2] && this.Balls[3] == other.Balls[3]) { WinType = 6; return(1); } else if (this.Balls[0] == other.Balls[0] && this.Balls[1] == other.Balls[1] && this.Balls[2] == other.Balls[2] && this.RedBall == other.RedBall) { WinType = 5; return(1); } else if (this.Balls[0] == other.Balls[0] && this.Balls[1] == other.Balls[1] && this.Balls[2] == other.Balls[2]) { WinType = 4; return(1); } else if (this.Balls[0] == other.Balls[0] && this.Balls[1] == other.Balls[1] && this.RedBall == other.RedBall) { WinType = 3; return(1); } else if (this.Balls[0] == other.Balls[0] && this.RedBall == other.RedBall) { WinType = 2; return(1); } else if (this.RedBall == other.RedBall) { WinType = 1; return(1); } return(-1); }
private void PowerBall_Play_Button_Click(object sender, EventArgs e) { Random random = new Random(); int[] PlayerBalls = { (int)Ball1numericUpDown.Value, (int)Ball2numericUpDown.Value, (int)Ball3numericUpDown.Value, (int)Ball4numericUpDown.Value, (int)Ball5numericUpDown.Value, (int)Ball5numericUpDown.Value }; int PlayerRedBall = (int)Ball6numericUpDown.Value; int[] ActualBaseBalls = { random.Next(1, 70), random.Next(1, 70), random.Next(1, 70), random.Next(1, 70), random.Next(1, 70), random.Next(1, 70) }; int ActualRedBall = random.Next(1, 27); int Winnings = 0; Ball1.Text = Convert.ToString(ActualBaseBalls[0]); Ball2.Text = Convert.ToString(ActualBaseBalls[1]); Ball3.Text = Convert.ToString(ActualBaseBalls[2]); Ball4.Text = Convert.ToString(ActualBaseBalls[3]); Ball5.Text = Convert.ToString(ActualBaseBalls[4]); Ball6.Text = Convert.ToString(ActualRedBall); PowerBall Player = new PowerBall(PlayerBalls, PlayerRedBall); PowerBall Computer = new PowerBall(ActualBaseBalls, ActualRedBall); Bet <PowerBall> TryBet = new Bet <PowerBall>(); TryBet.Player = Player; TryBet.Computer[0] = Computer; if (TryBet.DoBet() == 1) { if (TryBet.Player.WinType == 9) { Winnings = Convert.ToInt32(Total_Winnings.Text); Winnings += 100000000; Total_Winnings.Text = Convert.ToString(Winnings); } else if (TryBet.Player.WinType == 8) { Winnings = Convert.ToInt32(Total_Winnings.Text); Winnings += 1000000; Total_Winnings.Text = Convert.ToString(Winnings); } else if (TryBet.Player.WinType == 7) { Winnings = Convert.ToInt32(Total_Winnings.Text); Winnings += 50000; Total_Winnings.Text = Convert.ToString(Winnings); } else if (TryBet.Player.WinType == 6 || TryBet.Player.WinType == 5) { Winnings = Convert.ToInt32(Total_Winnings.Text); Winnings += 100; Total_Winnings.Text = Convert.ToString(Winnings); } else if (TryBet.Player.WinType == 4 || TryBet.Player.WinType == 3) { Winnings = Convert.ToInt32(Total_Winnings.Text); Winnings += 7; Total_Winnings.Text = Convert.ToString(Winnings); } else if (TryBet.Player.WinType == 2 || TryBet.Player.WinType == 1) { Winnings = Convert.ToInt32(Total_Winnings.Text); Winnings += 4; Total_Winnings.Text = Convert.ToString(Winnings); } PBWin.Text = "Winner!!"; } PBWin.Text = "Loser!!"; int Curr_Losses = Convert.ToInt32(Total_Losses.Text); Total_Losses.Text = Convert.ToString(Curr_Losses += 1); }