Beispiel #1
0
        public void guessButton_Click(int guessTotal, object sender, EventArgs e)
        {
            guessTotal++;

            int guess = Convert.ToInt16(inputBox.Text);

            //add guess to List of guesses on Form1
            guessList.Add(guess);

            if (guess < rand)
            {
                outputLabel.Text = "Too Low!";
            }
            else if (guess > rand)
            {
                outputLabel.Text = "Too High!";
            }
            else
            {
                outputLabel.Text = "You Got it!";
                Refresh();
                Thread.Sleep(1000);

                //close this screen and open a Results Screen (you need to create this)
                Form MS = this.FindForm();
                MS.Controls.Remove(this);

                ResultsScreen RS = new ResultsScreen();
                MS.Controls.Add(RS);
            }

            inputBox.Text = "";
            inputBox.Focus();
        }
        private void guessButton_Click(object sender, EventArgs e)
        {
            int guess = Convert.ToInt16(inputBox.Text);

            // add guess to List of guesses on Form1
            Form1.userGuesses.Add(guess);

            if (guess < rand)
            {
                outputLabel.Text = "Too Low!";
            }
            else if (guess > rand)
            {
                outputLabel.Text = "Too High!";
            }
            else
            {
                outputLabel.Text = "You Got it!";
                Refresh();
                Thread.Sleep(1000);

                //TODO close this screen and open a Results Screen (you need to create this)
                Form f = this.FindForm();
                f.Controls.Remove(this);

                // create an instance of the welcome screen
                ResultsScreen rs = new ResultsScreen();

                // Add the user control to the form
                f.Controls.Add(rs);
            }
            inputBox.Text = "";
            inputBox.Focus();
        }
Beispiel #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //launch the Main Screen
            ResultsScreen rs = new ResultsScreen();

            MainScreen ms = new MainScreen();

            this.Controls.Add(ms);
        }
        private void guessButton_Click(object sender, EventArgs e)
        {
            outputLabel.Text      = "";
            outputLabel.ForeColor = Color.White;

            try // try to convert input
            {
                guess   = Convert.ToInt16(inputBox.Text);
                numTrue = true;
            }
            catch   // if input is not an integer run this
            {
                outputLabel.ForeColor = Color.Red;
                outputLabel.Text      = "Please enter a number";
                Refresh();
                Thread.Sleep(1000);

                numTrue = false;
            }

            Form1.userGuesses.Add(guess);

            if (guess < rand && numTrue)
            {
                outputLabel.Text = "Too Low!";
            }
            else if (guess > rand && numTrue)
            {
                outputLabel.Text = "Too High!";
            }
            else if (guess == rand && numTrue)
            {
                outputLabel.Text = "You Got it!";
                Refresh();
                Thread.Sleep(1000);

                Form f = this.FindForm();
                f.Controls.Remove(this);

                ResultsScreen rs = new ResultsScreen();
                f.Controls.Add(rs);
                this.Refresh();
            }

            numTrue       = false;
            inputBox.Text = "";
            inputBox.Focus();
        }
        private void guessButton_Click(object sender, EventArgs e)
        {
            try
            {
                int guess =
                    Convert.ToInt16(inputBox.Text);

                //TODO add guess to List of guesses on Form1
                Form1.egg.Add(guess);

                Form1.numGuess++;

                if (guess < rand)
                {
                    outputLabel.Text = "Too Low!";
                }
                else if (guess > rand)
                {
                    outputLabel.Text = "Too High!";
                }
                else
                {
                    outputLabel.Text = "You Got it!";
                    Refresh();
                    Thread.Sleep(1000);
                    //Form1.bean = true;

                    //TODO close this screen and open a Results Screen (you need to create this)
                    Form f = this.FindForm();
                    f.Controls.Remove(this);

                    ResultsScreen rs = new ResultsScreen();
                    f.Controls.Add(rs);
                }
            }
            catch
            {
                outputLabel.Text = "Stinky Boy!";
            }


            inputBox.Text = "";
            inputBox.Focus();
        }
Beispiel #6
0
        private void guessButton_Click(object sender, EventArgs e)
        {
            try
            {
                int guess = Convert.ToInt16(inputBox.Text);

                //TODO add guess to List of guesses on Form1
                Form1.guesses.Add(guess);

                if (guess < rand)
                {
                    outputLabel.Text = "Too Low!";
                }
                else if (guess > rand)
                {
                    outputLabel.Text = "Too High!";
                }
                else
                {
                    outputLabel.Text = "You Got it!";
                    Refresh();
                    Thread.Sleep(1000);

                    //TODO close this screen and open a Results Screen (you need to create this)
                    Form f = this.FindForm();
                    f.Controls.Remove(this);
                    ResultsScreen re = new ResultsScreen();
                    f.Controls.Add(re);
                }

                inputBox.Text = "";
                inputBox.Focus();
            }
            catch
            {
                //error code
                outputLabel.Text = "Please enter a number.";
            }
        }
Beispiel #7
0
        private void guessButton_Click(object sender, EventArgs e)
        {
            try
            {
                //copies user input into guess variable
                guess = Convert.ToInt16(inputBox.Text);

                //adds guess to List of guesses on Form1
                Form1.guessList.Add(guess);

                if (guess < rand)
                {
                    outputLabel.Text = "Too Low!";
                }
                else if (guess > rand)
                {
                    outputLabel.Text = "Too High!";
                }
                else
                {
                    outputLabel.Text = "You Got it!";
                    Refresh();
                    Thread.Sleep(1000);

                    //closes this screen and opens a Results Screen
                    Form f = this.FindForm();
                    f.Controls.Remove(this);
                    ResultsScreen rs = new ResultsScreen();
                    f.Controls.Add(rs);
                }
            }
            catch { MessageBox.Show("OH NOS, YOU HAVE DONE IT THIS TIME!"); }

            inputBox.Text = "";
            inputBox.Focus();
        }