Esempio n. 1
0
        //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);
        }
Esempio n. 2
0
        //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();
        }
Esempio n. 3
0
 //Purpose:To begin the next round
 //Requires :Nothing
 //Returns : Nothing
 private void Next_Round_button_Click(object sender, EventArgs e)
 {
     Question_Box.Show();
     Next_Round_button.Hide();
     c = 0; // resets c to 0 for player questions
     rounds();
 }
Esempio n. 4
0
        //Purpose:To spin the board and see if the player is awarded
        //and cash
        //Requires:At least one player has a spin
        //Returns::Nothing
        private void SpinButton_Click(object sender, EventArgs e)
        {
            //checks to see if all the players have finished spinning
            if (p1.Espins == 0 && p2.Espins == 0 && p3.Espins == 0)
            {
                MessageBox.Show("No one has any spins left", "Spin", MessageBoxButtons.OK);
                SpinButton.Hide();
                if (round2 == 0)
                {
                    Next_Round_button.Show(); // goes to the next round
                    round2++;                 //icrements it by one so it is unable
                }
                else
                {
                    displayWinners(); // if two rounds played it goes to the winner function
                }
            }

            //if the players have spins
            else
            {
                Question_Box.Hide();
                Boarder_Box.Show();
                playerSpins(); //process the spins
            }
        }
Esempio n. 5
0
 //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();
 }
Esempio n. 6
0
 //Purpose: To remove the Question_Box that currently has the
 //Spin instructions
 //Requires:Nothing
 //Returns:Nothing
 private void Begin_Spin_Round_Click(object sender, EventArgs e)
 {
     Question_Box.Hide();
     SpinButton.Show();
     Begin_Spin_Round.Hide();
     Boarder_Box.Show();
     Quit_Button.Show();
     checkSpin(); //checks to see who goes first
 }
Esempio n. 7
0
 //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 "));
 }
Esempio n. 8
0
        //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
        }
Esempio n. 9
0
 //Purpose: When Clicked it will output the instructions for the game
 //and show and hide any components that is needed
 //Requires: Nothing
 //Returns: Nothing
 private void Play_Button_Click(object sender, EventArgs e)
 {
     Question_Box.Show();
     Question_Box.Font = new Font("Arial", 15, FontStyle.Regular);
     Question_Box.AppendText(string.Format("Welcome to the Press Your Luck Game!"));
     Question_Box.AppendText(string.Format(" This is a Game Played with Three Players!"));
     Question_Box.AppendText(string.Format(" You will first answer four trivia questions."));
     Question_Box.AppendText(string.Format(" After that starting with player."));
     Question_Box.AppendText(string.Format(" earn money"));
     Question_Box.AppendText(string.Format(" by spinning a randomly moving board."));
     Question_Box.AppendText(string.Format(" Watch out though hit a whammy and lose it all."));
     Question_Box.AppendText(string.Format("Once all names are entered please"));
     Question_Box.AppendText(string.Format(" hit Start Game to continue!\n"));
     Question_Box.AppendText(string.Format("Now, will you please enter in your name's"));
     Play_Button.Hide();
     Set_Name.Show();
     Player1_textBox.Show();
     playertwo_TextBox.Show();
     Playerthree_textBox.Show();
     Playerthree_label.Show();
     Playertwo_Label.Show();
     Playerone_Label.Show();
 }
Esempio n. 10
0
        //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();
        }
Esempio n. 11
0
        //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++;
                }
            }
        }