예제 #1
0
        /// <summary>
        /// Check Answer if Submit button is clicked
        /// </summary>
        /// <param name="e"></param>
        private void CheckAnswer(RoutedEventArgs e)
        {
            //Check and see if the answer is right, if it is add one to score
            if (Int32.Parse(AnswerBox.Text) == game.getAnswer(counter))
            {
                counter++;
                GradeLabel.Content = "Correct";
                player.addUserScore();
            }
            else
            {
                counter++;
                GradeLabel.Content = "Incorrect";
            }

            if (counter >= 10)
            {
                FinalScoreWindow final = new FinalScoreWindow(player);
                MyTimer.Stop();
                counter = 0;
                this.Hide();
                final.ShowDialog();
            }
            else
            {
                // List the new Question
                QuestionLabel.Content = game.questionToString(counter);
            }

            AnswerBox.Text = "";
        }
예제 #2
0
        /// <summary>
        /// Checks answer to see if it is correct or incorrect
        /// </summary>
        /// <param name="e"></param>
        private void CheckAnswer(KeyEventArgs e)
        {
            ///Exception handling for the normal method
            try
            {
                if (e.Key == Key.Enter)
                {
                    //Check and see if the answer is right, if it is add one to score
                    if (Int32.Parse(AnswerBox.Text) == game.getAnswer(counter))
                    {
                        counter++;
                        GradeLabel.Content = "Correct";
                        player.addUserScore();
                    }
                    else
                    {
                        counter++;
                        GradeLabel.Content = "Incorrect";
                    }

                    if (counter >= 10)
                    {
                        MyTimer.Stop();
                        counter = 0;
                        FinalScoreWindow final = new FinalScoreWindow(player);
                        if (player.getUserScore() <= 4)
                        {
                            final.BackgroundImage.ImageSource = new BitmapImage(new Uri(@"Images/LizardMan.jpg", UriKind.Relative));
                        }
                        else if (player.getUserScore() >= 5 || player.getUserScore() <= 7)
                        {
                            final.BackgroundImage.ImageSource = new BitmapImage(new Uri(@"Images/Background1.jpg", UriKind.Relative));
                        }
                        else
                        {
                            final.BackgroundImage.ImageSource = new BitmapImage(new Uri(@"Images/Background2.jpg", UriKind.Relative));
                        }

                        final.ShowDialog();
                    }
                    else
                    {
                        // List the new Question
                        QuestionLabel.Content = game.questionToString(counter);
                    }

                    AnswerBox.Text = "";
                }
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                                    MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }
예제 #3
0
 /// <summary>
 /// Method shows the FinalScoreWindow by creating a new instance and shows it as a Dialog
 /// </summary>
 public void showFinalScoresWindow()
 {
     try
     {
         if (this.mGameLogic != null && this.mGameLogic.getPlayer() != null)
         {
             hideMainErrorLabel();
             mFinalScoreWindow = new FinalScoreWindow(this);
             mFinalScoreWindow.ShowDialog();
         }
         else
         {
             showMainErrorLabel();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }