码迷,mamicode.com
首页 > 其他好文 > 详细

三次作业

时间:2015-10-19 00:23:38      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

  1 using System;
  2 using System.Collections.Generic;
  3 using System.ComponentModel;
  4 using System.Data;
  5 using System.Drawing;
  6 using System.Linq;
  7 using System.Text;
  8 using System.Windows.Forms;
  9 
 10 namespace 计算器
 11 {
 12     public partial class Form1 : Form
 13     {
 14         public static int Count = 0;
 15         private int t = 60;
 16         public static int right = 0;
 17         public static int fault = 0;
 18 
 19         public Form1()
 20         {
 21             InitializeComponent();
 22         }
 23 
 24        
 25         private void button1_Click(object sender, EventArgs e)
 26         {
 27             label2.Text = "+";
 28       
 29         }
 30 
 31         private void button2_Click(object sender, EventArgs e)
 32         {
 33             label2.Text = "-";
 34            
 35         }
 36         private void button3_Click(object sender, EventArgs e)
 37         {
 38             label2.Text = "*";
 39            
 40         }
 41         private void button4_Click(object sender, EventArgs e)
 42         {
 43             label2.Text = "/";
 44             
 45         }
 46 
 47         private void RandomNum()
 48         {
 49             Random ran = new Random();
 50             int n1, n2;
 51             n1 = ran.Next(0, 11);
 52             n2 = ran.Next(1, 11);
 53             textBox1.Text = n1.ToString();
 54             textBox2.Text = n2.ToString();
 55             textBox3.Text = "";
 56             Count++;
 57         }
 58         private void button6_Click(object sender, EventArgs e)
 59         {
 60             textBox3.Enabled = false;
 61             MessageBox.Show("总题目数为:" + Count + "   " + "正确个数为:" + fault + "   "+"错误个数为:"+(Count -fault ));
 62 
 63         }
 64         private void textBox3_KeyDown(object sender, KeyEventArgs e)
 65         {          
 66             int m;
 67             if (e.KeyCode == Keys.Enter)
 68             {
 69                 switch (label4.Text)
 70                 {
 71                     case "+":
 72                         m = int.Parse(textBox2.Text) + int.Parse(textBox3.Text);
 73                         break;
 74                     case "-":
 75                         m = int.Parse(textBox2.Text) - int.Parse(textBox3.Text);
 76                         break;
 77                     case "*":
 78                         m = int.Parse(textBox2.Text) * int.Parse(textBox3.Text);
 79                         break;
 80                     default:
 81                         m = int.Parse(textBox2.Text) / int.Parse(textBox3.Text);
 82                         break;
 83                 }
 84                 if (textBox3.Text == Convert.ToString(m))
 85                 {
 86                     right++;
 87                     RandomNum();
 88                 }
 89                 else
 90                 {
 91                     fault++;
 92                     RandomNum();
 93                 }
 94             }
 95         }
 96         private void button5_Click(object sender, EventArgs e)
 97         {
 98             label4.Text = t.ToString();
 99             timer1.Enabled = true;
100             timer1.Interval = 1000;
101             timer1.Start();
102             RandomNum();
103         }
104         private void timer1_Tick(object sender, EventArgs e)
105         {
106             if (t <= 0)
107             {
108                 timer1.Enabled = false;
109                 textBox3.Enabled = false;
110                 MessageBox.Show("时间到!!!");
111                 textBox3.Enabled = false;
112               
113             }
114             t = t - 1;
115             label4.Text = t.ToString();
116         }
117 }

技术分享

技术分享

有些地方我们没有做到点。

三次作业

标签:

原文地址:http://www.cnblogs.com/wang1/p/4890593.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!