//Purpose:to Display the winners and ask if the players //would like to play again //Requires:the players current cash from the player class //Returns:Nothing private void displayWinners() { Question_Box.Show(); Question_Box.Clear(); //Conditional statements to see who has the most cash if (p1.cash > p2.cash && p1.cash > p3.cash) { Question_Box.AppendText(p1.pName + " is the winner! With $" + p1.cash + "\n"); Question_Box.AppendText("Would you like to play another game?"); } else if (p2.cash > p1.cash && p2.cash > p3.cash) { Question_Box.AppendText(p2.pName + " is the winner! With $" + p2.cash + "\n"); Question_Box.AppendText("Would you like to play another game?"); } else if (p3.cash > p1.cash && p3.cash > p2.cash) { Question_Box.AppendText(p3.pName + " is the winner! With $" + p3.cash + "\n"); Question_Box.AppendText("Would you like to play another game?"); } else { Question_Box.AppendText(p1.pName + " " + p2.pName + " " + p3.pName + " Looks like no one won!\n"); Question_Box.AppendText("Would you like to play another game?"); } Yes_Button.Show(); No_Button.Show(); }
//Purpose: To check and see if the answer is correct or not //Requires:The answer key, and a boolean value preset to false //Retuns: True or false private bool checkQuestion() { //recives the typed in answer from the answer_box //and will allow it to be typed in using any form or string useranswer = Answers_Textbox.Text.ToUpper(); //sets the answer key to answer answer = quesAns.Value.ToUpper(); //Conditional statement to tell the user //if the answer is correct or not if (useranswer == answer) { Question_Box.Clear(); Question_Box.AppendText("You are Correct!"); Answer_Button.Hide(); Next_Question_Button.Show(); return(true); } else { Question_Box.Clear(); } Question_Box.AppendText("That is Incorrect! "); Question_Box.AppendText("The correct answer was " + quesAns.Value); Answer_Button.Hide(); Next_Question_Button.Show(); return(false); }
//Purpose:When clicked it will get the next question from the //dictionary and output it to the screen //Requires: A file to have been opened and a dictonary to have been filled //Reutns:Nothing private void Next_Question_Button_Click_1(object sender, EventArgs e) { Question_Box.Clear(); Answers_Textbox.Clear(); quesAns = getQuestions.ElementAt <KeyValuePair <string, string> >(random.Next(0, 74)); Question_Box.AppendText(quesAns.Key); Answer_Button.Show(); }
//Purpose::To output the Spin instructions to the screen //Requires Nothing //returns: Nothing private void spinInstructions() { Question_Box.Clear(); Question_Box.Font = new Font("Arial", 15, FontStyle.Regular); Question_Box.AppendText(string.Format("We will now begin the Spin Round! ")); Question_Box.AppendText(string.Format("Starting with " + p1.pName + " each player will")); Question_Box.AppendText(string.Format(" take turns earning cash by spinning the board")); Question_Box.AppendText(string.Format(" Each time you land on a whammy,")); Question_Box.AppendText(string.Format(" you lose ALL of your money. ")); Question_Box.AppendText(string.Format(" Press the Start Spinner to begin ")); }
//Purpose: Begins the rounds and gets the first question and tells //Player one to go first //Requires: Nothing //Retuns: Nothing private void rounds() { int index = random.Next(0, 74); //Finds a randon number for the question Answer_Button.Show(); Question_Box.Clear(); Answers_Textbox.Show(); //Conditional loop that tells player one they answer first while (x < 1) { Question_Box.AppendText(p1.pName + " you are up first!"); Question_Box.AppendText("\n\n"); x += 2; } //Gets the Question and answer quesAns = getQuestions.ElementAt <KeyValuePair <string, string> >(index); Question_Box.AppendText(quesAns.Key); x = 0;//used to reset the loop back to 0 for the next round }