第四次作业

  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 WindowsFormsApplication1
 11 {
 12     public partial class Form1 : Form
 13     {
 14         public Form1()
 15         {
 16             InitializeComponent();
 17         }
 18         public static int count = 0;
 19         private int t = 60;
 20         public static int right = 0;
 21         public int result;
 22         private void button5_Click(object sender, EventArgs e)
 23         {
 24             try
 25             {
 26                 t = int.Parse(textBox4.Text);
 27                 if (t > 0)
 28                 {
 29                     label2.Text = t.ToString();
 30                     textBox4.Enabled = false;
 31                 }
 32                 else
 33                 {
 34                     MessageBox.Show("输入数不能小于1,不能也带小数!");
 35                     return;
 36                 }
 37             }
 38             catch (Exception)
 39             {
 40                 
 41                 throw;
 42             }
 43             timer1.Enabled = true;
 44             timer1.Interval = 1000;
 45             timer1.Start();
 46             Random();
 47 
 48         }
 49         private void Random()
 50          {
 51             Random ab = new Random();
 52 
 53             int a, b;
 54             a = ab.Next(1, 11);
 55             b = ab.Next(1, 11);
 56             textBox1.Text = a.ToString();
 57             textBox2.Text = b.ToString();
 58             textBox3.Text = "";
 59             count++;   
 60 
 61         }
 62         private void timer1_Tick(object sender, EventArgs e)
 63         {
 64             if (t <= 0)
 65             {
 66                 timer1.Enabled = false;
 67                 textBox3.Enabled = false;
 68                 MessageBox.Show("时间到!");
 69                 textBox3.Enabled = false;
 70             }
 71             t = t - 1;
 72             label2.Text = t.ToString();
 73             
 74 
 75        }
 76 
 77         private void button1_Click(object sender, EventArgs e)
 78         {
 79             label3.Text = "+";
 80         }
 81 
 82         private void button2_Click(object sender, EventArgs e)
 83         {
 84             label3.Text = "-";
 85         }
 86 
 87         private void button3_Click(object sender, EventArgs e)
 88         {
 89             label3.Text ="*";
 90         }
 91 
 92         private void button4_Click(object sender, EventArgs e)
 93         {
 94             label3.Text = "/";
 95         }
 96 
 97         private void textBox3_KeyDown(object sender, KeyEventArgs e)
 98         {
 99             
100             if (e.KeyCode == Keys.Enter)
101             {
102                 switch (label3.Text)
103                 {
104                     case "+":
105                         result = int.Parse(textBox1.Text) + int.Parse(textBox2.Text);
106                         break;
107                     case "-":
108                         result = int.Parse(textBox1.Text) - int.Parse(textBox2.Text);
109                         break;
110                     case "*":
111                         result = int.Parse(textBox1.Text) * int.Parse(textBox2.Text);
112                         break;
113                     case "/":
114                         result = int.Parse(textBox1.Text) / int.Parse(textBox2.Text);
115                         break;
116                          }
117 
118                 if (textBox3.Text == result.ToString())
119                 {
120 
121                     right++;
122                     Random();
123                 }
124                 else
125                 {
126                     Random();
127                 }
128                            
129             }
130         }
131 
132 
133         private void button6_Click(object sender, EventArgs e)
134         {
135             textBox3.Enabled = false;
136             count--;
137             Form2 frm2 = new Form2();
138             frm2.ShowDialog();
139         }
140         private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
141         {
142             //在网上找到的关于用户输入非数字的判断,但是并不完善 , 如果设置messagebox则会在按下回车键时弹出。
143             if (!char.IsDigit(e.KeyChar))
144             {
145                 e.Handled = true;
146                 //MessageBox.Show("请输入数字");
147                 
148             }
149         }
150     }
151 }

psp2.1    
  计划

3h

  估计这个任务需要多少时间 3h
 

开发

3h
 

需求分析

10
  生成设计文档 30
  设计复审 10
  代码规范 10
  具体设计 60
  具体编码 40
  代码复审 10
  测试 20
 

报告

10
  测试报告 10
  计算工作量 3
  事后总结。并提出改进 10

有不少问题不会 只能上网搜索

posted @ 2015-10-24 19:53  夏yongyong  阅读(120)  评论(0编辑  收藏  举报