• 第四次作业


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            public static int count = 0;
            private int t = 60;
            public static int right = 0;
            public int result;
            private void button5_Click(object sender, EventArgs e)
            {
                try
                {
                    t = int.Parse(textBox4.Text);
                    if (t > 0)
                    {
                        label2.Text = t.ToString();
                        textBox4.Enabled = false;
                    }
                    else
                    {
                        MessageBox.Show("输入数不能小于1,不能也带小数!");
                        return;
                    }
                }
                catch (Exception)
                {
                    
                    throw;
                }
                timer1.Enabled = true;
                timer1.Interval = 1000;
                timer1.Start();
                Random();
    
            }
            private void Random()
             {
                Random ab = new Random();
    
                int a, b;
                a = ab.Next(1, 11);
                b = ab.Next(1, 11);
                textBox1.Text = a.ToString();
                textBox2.Text = b.ToString();
                textBox3.Text = "";
                count++;   
    
            }
            private void timer1_Tick(object sender, EventArgs e)
            {
                if (t <= 0)
                {
                    timer1.Enabled = false;
                    textBox3.Enabled = false;
                    MessageBox.Show("时间到!");
                    textBox3.Enabled = false;
                }
                t = t - 1;
                label2.Text = t.ToString();
                
    
           }
    
            private void button1_Click(object sender, EventArgs e)
            {
                label3.Text = "+";
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                label3.Text = "-";
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                label3.Text ="*";
            }
    
            private void button4_Click(object sender, EventArgs e)
            {
                label3.Text = "/";
            }
    
            private void textBox3_KeyDown(object sender, KeyEventArgs e)
            {
                
                if (e.KeyCode == Keys.Enter)
                {
                    switch (label3.Text)
                    {
                        case "+":
                            result = int.Parse(textBox1.Text) + int.Parse(textBox2.Text);
                            break;
                        case "-":
                            result = int.Parse(textBox1.Text) - int.Parse(textBox2.Text);
                            break;
                        case "*":
                            result = int.Parse(textBox1.Text) * int.Parse(textBox2.Text);
                            break;
                        case "/":
                            result = int.Parse(textBox1.Text) / int.Parse(textBox2.Text);
                            break;
                             }
    
                    if (textBox3.Text == result.ToString())
                    {
    
                        right++;
                        Random();
                    }
                    else
                    {
                        Random();
                    }
                               
                }
            }
    
    
            private void button6_Click(object sender, EventArgs e)
            {
                textBox3.Enabled = false;
                Form2 frm2 = new Form2();
                frm2.ShowDialog();
            }
            private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
            {
                //在网上找到的关于用户输入非数字的判断,但是并不完善 , 如果设置messagebox则会在按下回车键时弹出。
                if (!char.IsDigit(e.KeyChar))
                {
                    e.Handled = true;
                    //MessageBox.Show("请输入数字");
                    
                }
            }
        }
    }


    psp 计划 3h
        估计这个任务需要多少时间 3h
      开发 3.1h
        需求分析 10
        生成设计文档 30
        设计复审 10
          代码规范 10
        具体设计 60
        具体编码 40
        代码复审 10
        测试 20
      报告 23
        测试报告 10
        计算工作量 3
        事后总结,并提出改进计划 10
         


            




    我俩从网上找了不少例子,跟着勇勇哥学到了不少东西,我看不懂的代码都问他,他也很乐意给我说,
    今天您告诉我们复制粘贴不好,我们也懂得,我们看到别人的代码之后呢,会去理解其中的意思,知其所以然。
    当作例子用。

      

  • 相关阅读:
    char 转string
    博客,记忆的图谱。
    history
    openstack Icehouse发布
    数据库常用命令
    nagios
    screen
    openstack 流量控制
    sublime 3
    磁盘类型
  • 原文地址:https://www.cnblogs.com/yintaiping/p/4907565.html
Copyright © 2020-2023  润新知