//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); }
//Below are the various functions used that are implemented in //the buttons listed above. //Purpose: To Hide all Components that are not //needed at the begining of the game //Requires:Nothing //Returns;Nothing private void hideComponents() { Question_Box.Hide(); Boarder_Box.Hide(); Answers_Textbox.Hide(); Answer_Button.Hide(); Start_Button.Hide(); Next_Question_Button.Hide(); SpinButton.Hide(); Begin_Spin_Round.Hide(); Spin_Round_Instruction.Hide(); Set_Name.Hide(); Player1_textBox.Hide(); playertwo_TextBox.Hide(); Playerthree_textBox.Hide(); Playerthree_label.Hide(); Playertwo_Label.Hide(); Playerone_Label.Hide(); Yes_Button.Hide(); No_Button.Hide(); Next_Round_button.Hide(); Quit_Button.Hide(); }
//Purpose: When clicked it will a bool value and call //check question to see if the answer is correct or not //then calls current player to output if they were wrong or not //Requires: A boolian value and the current player //Returns:Nothing for the button private void Answer_Button_Click_1(object sender, EventArgs e) { if (c <= 11) { bool a = checkQuestion(); if (c == 0 || c == 3 || c == 6 || c == 9) { if (a == true) { p1.Espins++; PlayeroneEspincount.Clear(); PlayeroneEspincount.AppendText(Convert.ToString(p1.Espins)); Question_Box.AppendText("\n\n\n"); Question_Box.AppendText(p2.pName + " it is your turn"); } else { Question_Box.AppendText("\n\n\n"); Question_Box.AppendText(p2.pName + " it is your turn"); } c++; } else if (c == 1 || c == 4 || c == 7 || c == 10) { if (a == true) { p2.Espins++; PlayertwoEspincount.Clear(); PlayertwoEspincount.AppendText(Convert.ToString(p2.Espins)); Question_Box.AppendText("\n\n\n"); Question_Box.AppendText(p3.pName + " it is your turn"); } else { Question_Box.AppendText("\n\n\n"); Question_Box.AppendText(p3.pName + " it is your turn"); } c++; } else { if (a == true) { p3.Espins++; PlayerthreeEspincount.Clear(); PlayerthreeEspincount.AppendText(Convert.ToString(p3.Espins)); Question_Box.AppendText("\n\n\n"); Question_Box.AppendText(p1.pName + " it is your turn"); } else { Question_Box.AppendText("\n\n\n"); Question_Box.AppendText(p1.pName + " it is your turn"); } if (c == 11) { Answer_Button.Hide(); Next_Question_Button.Hide(); Answers_Textbox.Hide(); Spin_Round_Instruction.Show(); } c++; } } }