private void button5_Click(object sender, EventArgs e) { Accountmanitain myobj = new Accountmanitain(); int b = myobj.Randomnumber(); MessageBox.Show("Congratulations ! \n Horse " + b + " Wins The Race"); // array to hold Mike betting details string[] MIKE = new string[10]; string labler = label1.Text; MIKE = labler.Split(' '); // array to hold Robert betting details string[] ROBERT = new string[10]; string roblabel = label2.Text; ROBERT = roblabel.Split(' '); // array to hold donald betting details string[] DONALD = new string[10]; string donaldlabel = label3.Text; DONALD = donaldlabel.Split(' '); if (b == Convert.ToInt32(MIKE[9])) { MessageBox.Show("Congratulations Mike wins the race"); if (mike.Count > 0) { int result = Convert.ToInt32(ROBERT[6]) + Convert.ToInt32(DONALD[6]); int mikeamount = Convert.ToInt32(mike[mike.Count - 1]); int totalresult = mikeamount + result; MessageBox.Show("Amount credited to Mike" + result); MessageBox.Show("Total Amount" + totalresult); mike.Add(totalresult); } int robreduction = Convert.ToInt32(robert.Last()) - Convert.ToInt32(ROBERT[6]); MessageBox.Show("Amount deducted from Tom account" + Convert.ToInt32(ROBERT[6])); MessageBox.Show("Amount remains in Rob account" + robreduction); robert.Add(robreduction); int donaldreduction = Convert.ToInt32(donald.Last()) - Convert.ToInt32(DONALD[6]); MessageBox.Show("Amount deducted from DONALD account" + Convert.ToInt32(DONALD[6])); MessageBox.Show("Amount remains in donald account" + donaldreduction); donald.Add(donaldreduction); // code to check player 2 is a winner if (Convert.ToInt32(robert.Last()) <= 0) { radioButton2.Enabled = false; label2.Text = "you are busted"; } if (Convert.ToInt32(donald.Last()) <= 0) { radioButton3.Enabled = false; label3.Text = "You are busted"; } } // code to find robert is a winner if (b == Convert.ToInt32(ROBERT[9])) { MessageBox.Show("Congratulations Robert wins the race"); if (robert.Count > 0) { int result = Convert.ToInt32(MIKE[6]) + Convert.ToInt32(DONALD[6]); int robertamount = Convert.ToInt32(robert[robert.Count - 1]); int totalresult = robertamount + result; MessageBox.Show("Amount credited to robert account" + result); MessageBox.Show("Total Amount" + totalresult); robert.Add(totalresult); } int mikereduction = Convert.ToInt32(mike.Last()) - Convert.ToInt32(MIKE[6]); MessageBox.Show("Amount deducted from Mike account" + Convert.ToInt32(MIKE[6])); MessageBox.Show("Amount remains in Mike account" + mikereduction); mike.Add(mikereduction); int donaldreduction = Convert.ToInt32(donald.Last()) - Convert.ToInt32(DONALD[6]); MessageBox.Show("Amount deducted from DONALD account" + Convert.ToInt32(DONALD[6])); MessageBox.Show("Amount remains in donald account" + donaldreduction); donald.Add(donaldreduction); int robreduction = Convert.ToInt32(robert.Last()) - Convert.ToInt32(ROBERT[6]); MessageBox.Show("Amount deducted from Tom account" + Convert.ToInt32(ROBERT[6])); MessageBox.Show("Amount remains in Rob account" + robreduction); robert.Add(robreduction); if (Convert.ToInt32(mike.Last()) <= 0) { radioButton1.Enabled = false; label1.Text = "you are busted"; } if (Convert.ToInt32(donald.Last()) <= 0) { radioButton3.Enabled = false; label3.Text = "You are busted"; } } // if statement to check tom is a winner or not if (b == Convert.ToInt32(DONALD[9])) { MessageBox.Show("Congratulations Donald wins the race"); int donaldresult = Convert.ToInt32(MIKE[6]) + Convert.ToInt32(ROBERT[6]);// if (donald.Count > 0) { int donaldamount = Convert.ToInt32(donald[donald.Count - 1]); int result1 = donaldamount + donaldresult; MessageBox.Show("Amount credited to Donald side" + donaldresult); MessageBox.Show("Total Amount" + result1); donald.Add(result1); } int mikereduction = Convert.ToInt32(mike.Last()) - Convert.ToInt32(MIKE[6]); MessageBox.Show("Amount deducted from Mike account" + Convert.ToInt32(MIKE[6])); MessageBox.Show("Amount remains in Mike account" + mikereduction); mike.Add(mikereduction); int robreduction = Convert.ToInt32(robert.Last()) - Convert.ToInt32(ROBERT[6]); MessageBox.Show("Amount deducted from Tom account" + Convert.ToInt32(ROBERT[6])); MessageBox.Show("Amount remains in Rob account" + robreduction); robert.Add(robreduction); if (Convert.ToInt32(mike.Last()) <= 0) { radioButton1.Enabled = false; label1.Text = "you are busted"; } if (Convert.ToInt32(robert.Last()) <= 0) { radioButton2.Enabled = false; label2.Text = "you are busted"; } } }
private void button5_Click(object sender, EventArgs e) { //timer2.Enabled = true; // timer4.Enabled = true; // timer5.Enabled = true; if (label1.Text == string.Empty) { MessageBox.Show("Please select the player, Amount and Betting Bike"); return; } else if (label2.Text == string.Empty) { MessageBox.Show("Please select the player, Amount and Betting Bike"); return; } else if (label3.Text == string.Empty) { MessageBox.Show("Please select the player, Amount and Betting Bike"); return; } Random randomnumber = new Random(); int r = randomnumber.Next(1, 5); MessageBox.Show("Bike " + r + " \n wins the race"); string[] john = new string[10]; string johnstring = label1.Text; john = johnstring.Split(' '); //timer3.Enabled=true; //this code splits the text and store in jack string array string[] michal = new string[10]; string michalstr = label2.Text; michal = michalstr.Split(' '); //this code splits the text and store in Tom string array string[] james = new string[10]; string jamesstr = label3.Text; james = jamesstr.Split(' '); // timer4.Enabled = true; int max = 45; Accountmanitain h = new Accountmanitain(); if (r == Convert.ToInt32(john[8])) { MessageBox.Show("Congrats! John Won the Bet "); int johnscore = Convert.ToInt32(michal[5]) + Convert.ToInt32(james[5]); int johnscore1 = Convert.ToInt32(johnlisting.Last()) + johnscore; MessageBox.Show("john is awarded with " + johnscore); MessageBox.Show("total John amount in your account " + johnscore1); //h.JohnupdateData(jscore1); johnlisting.Add(johnscore1); //code to deduct michal and james amount int michalreduction = Convert.ToInt32(michallisting.Last()) - Convert.ToInt32(michal[5]); MessageBox.Show("Amount deducted from Michal account " + michal[5]); MessageBox.Show("Remaining amount is john account " + michalreduction); michallisting.Add(michalreduction); int jamesreduction = Convert.ToInt32(jameslisting.Last()) - Convert.ToInt32(james[5]); MessageBox.Show("Amount deducted from James account " + james[5]); MessageBox.Show("Remaining amount is James account " + jamesreduction); jameslisting.Add(jamesreduction); //code to check whether james and michal amount reach 0 or not if (Convert.ToInt32(michallisting.Last()) <= 0) { radioButton2.Enabled = false; label2.Text = "you are busted"; } if (Convert.ToInt32(jameslisting.Last()) <= 0) { radioButton3.Enabled = false; label3.Text = "You are busted"; } //timer5.Enabled = true; } // code to check whether michal is a winner else if (r == Convert.ToInt32(michal[8])) { MessageBox.Show("Congrats! Michal Wins the Bet "); int mscore = Convert.ToInt32(john[5]) + Convert.ToInt32(james[5]); int mscore1 = mscore + Convert.ToInt32(michallisting.Last()); MessageBox.Show("Michal is awarded with" + mscore); MessageBox.Show("total amount in michal account" + mscore1); michallisting.Add(mscore1); //h.michalupdateData(mscore1); int jamesreduction = Convert.ToInt32(jameslisting.Last()) - Convert.ToInt32(james[5]); MessageBox.Show("Amount deducted from James account " + james[5]); MessageBox.Show("Remaining amount is James account " + jamesreduction); jameslisting.Add(jamesreduction); int johnreduction = Convert.ToInt32(johnlisting.Last()) - Convert.ToInt32(john[5]); MessageBox.Show("Amount deducted from John account " + john[5]); MessageBox.Show("Remaining amount is John account " + johnreduction); johnlisting.Add(johnreduction); if (Convert.ToInt32(jameslisting.Last()) <= 0) { radioButton3.Enabled = false; label3.Text = "You are busted"; } if (Convert.ToInt32(johnlisting.Last()) <= 0) { radioButton1.Enabled = false; label1.Text = "You are busted"; } //timer5.Enabled = true; } //code to check whether james is a winner else if (r == Convert.ToInt32(james[8])) { MessageBox.Show("Congrats! James Won the Bet "); int jamesscore = Convert.ToInt32(john[5]) + Convert.ToInt32(michal[5]); int jamesscore1 = jamesscore + Convert.ToInt32(jameslisting.Last()); MessageBox.Show("James is awarded with" + jamesscore); MessageBox.Show("Total amount in james account" + jamesscore1); jameslisting.Add(jamesscore1); int michalreduction = Convert.ToInt32(michallisting.Last()) - Convert.ToInt32(michal[5]); MessageBox.Show("Amount deducted from Michal account " + michal[5]); MessageBox.Show("Remaining amount is john account " + michalreduction); michallisting.Add(michalreduction); int johnreduction = Convert.ToInt32(johnlisting.Last()) - Convert.ToInt32(john[5]); MessageBox.Show("Amount deducted from John account " + john[5]); MessageBox.Show("Remaining amount is John account " + johnreduction); johnlisting.Add(johnreduction); if (Convert.ToInt32(johnlisting.Last()) <= 0) { radioButton1.Enabled = false; label1.Text = "You are busted"; } if (Convert.ToInt32(michallisting.Last()) <= 0) { radioButton2.Enabled = false; label2.Text = "you are busted"; } //timer5.Enabled = true; } }