예제 #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (sc == d.ToString())
     {
         score += 1;
         timer1.Stop();
         t = 2000;
         timer1.Start();
         progressBar1.Value = 0;
         Random rd = new Random();
         a = rd.Next(0, 9);
         b = rd.Next(1, 9);
         c = rd.Next(0, 4);
         if (c == 0)
         {
             s      = " + ";
             result = a + b;
             d      = result - rd.Next(0, 3);
         }
         else if (c == 1)
         {
             s      = " - ";
             result = a - b;
             d      = result + rd.Next(0, 3);
         }
         else if (c == 2)
         {
             s      = " x ";
             result = a * b;
             d      = result - rd.Next(0, 3);
         }
         else
         {
             s      = " / ";
             result = a / b;
             d      = result + rd.Next(0, 3);
         }
         sa = a.ToString();
         sb = b.ToString();
         c  = rd.Next(0, 3);
         if (c == 0)
         {
             sc = result.ToString();
         }
         else if (c == 2)
         {
             sc = d.ToString();
         }
         else
         {
             sc = d.ToString();
         }
         label1.Text = sa + s + sb + " = " + sc;
     }
     else
     {
         timer1.Stop();
         MessageBox.Show("Your score: " + score, "Info");
         this.Hide();
         Form1 f = new Form1();
         this.Close();
         f.ShowDialog();
         score = 0;
     }
 }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Form1 frm = new Form1();

            frm.ShowDialog();
        }