コード例 #1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            i = 0;
            TImerForAnswer.Start();
            textBox1.Enabled = true;
            Random seed    = new Random();
            int    Number1 = seed.Next(10) + 1;

            label2.Text       = Number1.ToString();
            pictureBox1.Image = Image.FromFile(Number1.ToString() + "Hard" + ".png");

            int Number2 = seed.Next(10) + 1;

            label3.Text       = Number2.ToString();
            pictureBox2.Image = Image.FromFile(Number2.ToString() + "Hard" + ".png");

            int Number3 = seed.Next(10, 20) + 1; //Limits the numbers to randomize 10 through to 20

            label4.Text       = Number3.ToString();
            pictureBox3.Image = Image.FromFile("Hard" + Number3.ToString() + ".png");
            sum = Number1 * Number2 + Number3;
        }
コード例 #2
0
        private void BtnAnswer_Click(object sender, EventArgs e)
        {
            i = 0;
            TImerForAnswer.Start();

            int Answer = int.Parse(textBox1.Text);

            if (sum == Answer)
            {
                correctCount = correctCount + 1;
                MessageBox.Show("Well done!");
            }
            else
            {
                MessageBox.Show("Try again! The correct answer was " + sum);
            }

            totalcount      = totalcount + 1;
            lblAttempt.Text = totalcount.ToString();
            lblCorrect.Text = correctCount.ToString();
            Random seed    = new Random();
            int    Number1 = seed.Next(10) + 1;

            label2.Text       = Number1.ToString();
            pictureBox1.Image = Image.FromFile(Number1.ToString() + "Hard" + ".png");

            int Number2 = seed.Next(10) + 1;

            label3.Text       = Number2.ToString();
            pictureBox2.Image = Image.FromFile(Number2.ToString() + "Hard" + ".png");

            int Number3 = seed.Next(10, 20) + 1; //Limits the numbers to randomize 10 through to 20

            label4.Text       = Number3.ToString();
            pictureBox3.Image = Image.FromFile("Hard" + Number3.ToString() + ".png");
            sum = Number1 * Number2 + Number3;
        }
コード例 #3
0
 public Harder_Game()
 {
     InitializeComponent();
     TImerForAnswer.Start();
 }