第四次作业
1 private void Form2_Load(object sender, EventArgs e) 2 { 3 textBox1.Text = Form1.Count.ToString(); 4 textBox2.Text = Form1.fault.ToString(); 5 // textBox3.Text = Form1.right.ToString();
1 public partial class Form1 : Form 2 { 3 public static int Count = 0; 4 private int t = 60; 5 public static int right = 0; 6 public static int fault = 0; 7 8 public Form1() 9 { 10 InitializeComponent(); 11 } 12 13 private void button4_Click(object sender, EventArgs e) 14 { 15 label2.Text = "/"; 16 // RandomNum(); 17 } 18 19 private void button1_Click(object sender, EventArgs e) 20 { 21 label2.Text = "+"; 22 // RandomNum(); 23 } 24 25 private void button2_Click(object sender, EventArgs e) 26 { 27 label2.Text = "-"; 28 // RandomNum(); 29 } 30 private void button3_Click(object sender, EventArgs e) 31 { 32 label2.Text = "*"; 33 // RandomNum(); 34 } 35 private void RandomNum() 36 { 37 Random ran = new Random(); 38 int n1, n2; 39 n1 = ran.Next(1, 11); 40 n2 = ran.Next(1, 11); 41 textBox1.Text = n1.ToString(); 42 textBox2.Text = n2.ToString(); 43 44 switch (label2.Text) 45 { 46 case "-": 47 while (true ) 48 { 49 if (int .Parse (textBox1 .Text )>=int.Parse (textBox2 .Text )) 50 { 51 break; 52 } 53 n1 = ran.Next(1, 11); 54 n2 = ran.Next(1, 11); 55 textBox1.Text = n1.ToString(); 56 textBox2.Text = n2.ToString(); 57 58 } 59 break; 60 case "/": 61 break; 62 } 63 textBox3.Text = ""; 64 Count++; 65 } 66 private void button6_Click(object sender, EventArgs e) 67 { 68 69 textBox3.Enabled = false; 70 Form2 frm2 = new Form2(); 71 frm2.ShowDialog(); 72 73 } 74 private void textBox3_KeyDown(object sender, KeyEventArgs e) 75 { 76 int m; 77 if (e.KeyCode == Keys.Enter) 78 { 79 switch (label2.Text) 80 { 81 case "+": 82 m = int.Parse(textBox2.Text) + int.Parse(textBox3.Text); 83 break; 84 case "*": 85 m = int.Parse(textBox2.Text) * int.Parse(textBox3.Text); 86 break; 87 default: 88 m = int.Parse(textBox2.Text) / int.Parse(textBox3.Text); 89 break; 90 } 91 if (textBox3.Text == Convert.ToString(m)) 92 { 93 right++; 94 RandomNum(); 95 } 96 else 97 { 98 fault++; 99 RandomNum(); 100 } 101 } 102 } 103 private void button5_Click(object sender, EventArgs e) 104 { 105 try 106 { 107 t = int.Parse(textBox4 .Text ); 108 if (t <= 0) 109 { 110 MessageBox.Show("时间不能为负数"); 111 return; 112 } 113 label4.Text = t.ToString(); 114 textBox4.Enabled = false; 115 } 116 catch (Exception) 117 { 118 MessageBox.Show("请输入正确的时间"); 119 return; 120 121 } 122 // label4.Text = t.ToString(); 123 124 timer1.Enabled = true; 125 timer1.Interval = 1000; 126 timer1.Start(); 127 RandomNum(); 128 } 129 private void timer1_Tick(object sender, EventArgs e) 130 { 131 if (t <= 0) 132 { 133 timer1.Enabled = false; 134 textBox4.Enabled = false; 135 MessageBox.Show("时间到!!!"); 136 textBox4.Enabled = false; 137 // txtTime.Enblaed = false; 138 Form2 frm2 = new Form2(); 139 frm2.ShowDialog(); 140 } 141 t = t - 1; 142 label4.Text = t.ToString(); 143 }
这次王斌同学的结队编程作业我知道了团队合作可以更好的完成项目,通过这次的结对编程做出来可以自己设定时间,在计算减法的时候不会出现结果是负数的情况,在这次作业中虽然遇到了很多团难,但都慢慢解决了,正如老师说的结队编程对我们的学习是有很大帮助的。今后会继续努力。
Personal Software Process Stages | 耗时(分钟) |
计划 | 20 |
估计用时 | 20 |
开发 | 180 |
需求分析 | 20 |
设计复审 | 20 |
代码规范 | 5 |
具体设计 | 40 |
具体编码 | 90 |
代码复审 | 10 |
测试 | 10 |
报告 | 20 |
测试报告 | 10 |
计算工作量 | 5 |
事后总结 | 20 |