首页 > 技术文章 > 个人作业-----计应191(西)高照达

yangjiahe 2021-05-31 22:23 原文

小学一年级100以内的加减法

1、计划:用c#编写一个小学生100以内口算题卡。

2、开发:

      需求分析:作为一名一年级小学生的家长,我希望开发出一个口算题卡软件,让我的孩子能在上面练习口算题,能够自动生成100以内的正整数加减法运算,以便减轻我的工作负担。

                         难点:自动出10道题,然后进行解答。

      代码规范:vs的代码规范。

      具体设计:

   

3、PSP阶段

      具体代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace shuxueti
{
    public partial class Form1 : Form
    {
        int[] jieguo = new int[10];//存储结果
       public DateTime Frist { get; set; }//计算时间
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.listBox1.DataSource = Data();
            this.lbtime.Text = "所用时间";
        }
        private List<String> Data() 
        {
            List<string> st = new List<string>(); 
            string s="";
            Random ran = new Random();
           // int[] jieguo = new int[10];
            //int a = ran.Next(100);
            //int b = ran.Next(100);
            //int c = ran.Next(1, 3);
            //TextBox t = new TextBox();
            //t.Name = "自定义";
            //this.Controls.Add(t);
            //t.Location = new Point(11, 11);
            for (int i = 0; i < 10; i++) 
            {
                int a = ran.Next(100);
                int b = ran.Next(100);
                int c = ran.Next(1, 3);
                switch (c)
                {
                    case 1:
                        if ((a + b) > 100) 
                        {
                            if (a > b)
                            {
                                s = a + "-" + b + "=";jieguo[i] = a - b;
                            }
                            else 
                            {
                                s = b + "-" + a + "="; jieguo[i] = b-a;
                            }
                        }
                        else 
                        {
                            s = a + "+" + b + "="; jieguo[i] = a + b;
                        }
                        break;
                    case 2:
                        if (a < b)
                        {
                            s= b + "-" + a + "="; jieguo[i] = b-a;
                        }
                        else
                        {
                            s = a + "-" + b + "="; jieguo[i] = a - b;
                        }
                        break;
                }
                st.Add (s);
            }
            return st;
        }

        private void btsumbit_Click(object sender, EventArgs e)
        {
            double reald = 0;
                if (txb1.Text == jieguo[0].ToString())
                {
                    this.lb1.Text = "";
                    reald++;
                }
                else
                {
                    this.lb1.Text = "×";
                }
            if (txb2.Text == jieguo[1].ToString())
            {
                this.lb2.Text = "";
                reald++;
            }
            else
            {
                this.lb2.Text = "×";
            }
            if (txb3.Text == jieguo[2].ToString())
            {
                this.lb3.Text = "";
                reald++;
            }
            else
            {
                this.lb3.Text = "×";
            }
            if (txb4.Text == jieguo[3].ToString())
            {
                this.lb4.Text = "";
                reald++;
            }
            else
            {
                this.lb4.Text = "×";
            }
            if (txb5.Text == jieguo[4].ToString())
            {
                this.lb5.Text = "";
                reald++;
            }
            else
            {
                this.lb5.Text = "×";
            }
            if (txb6.Text == jieguo[5].ToString())
            {
                this.lb6.Text = "";
                reald++;
            }
            else
            {
                this.lb6.Text = "×";
            }
            if (txb7.Text == jieguo[6].ToString())
            {
                this.lb7.Text = "";
                reald++;
            }
            else
            {
                this.lb7.Text = "×";
            }
            if (txb8.Text == jieguo[7].ToString())
            {
                this.lb8.Text = "";
                reald++;
            }
            else
            {
                this.lb8.Text = "×";
            }
            if (txb9.Text == jieguo[8].ToString())
            {
                this.lb9.Text = "";
                reald++;
            }
            else
            {
                this.lb9.Text = "×";
            }
            if (txb10.Text == jieguo[9].ToString())
            {
                this.lb10.Text = "";
                reald++;
            }
            else
            {
                this.lb10.Text = "×";
            }
            //double z = reald / 10;
            this.lbcr.Text = "正确率"+(reald / 10).ToString("P");

            DateTime last =DateTime.Now;
            TimeSpan cha = last - Frist;
            this.lbtime.Text ="所用时间" +cha.Seconds.ToString()+"";
        }

        private void txb1_KeyPress(object sender, KeyPressEventArgs e)
        {
            //IsNumber的作用是判断输入案件是否为数字
            //(char)8是退格键值,可以允许用户敲退格键对输入的数字进行修改
            //针对其他按键输入则提示错误不允许输入到文本框
            if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
            {
                e.Handled = true;//经判断为数字,可以输入
            }
        }

        private void txb2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
            {
                e.Handled = true;//经判断为数字,可以输入
            }
        }

        private void txb3_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
            {
                e.Handled = true;//经判断为数字,可以输入
            }
        }

        private void txb4_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
            {
                e.Handled = true;//经判断为数字,可以输入
            }
        }

        private void txb5_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
            {
                e.Handled = true;//经判断为数字,可以输入
            }
        }

        private void txb6_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
            {
                e.Handled = true;//经判断为数字,可以输入
            }
        }

        private void txb7_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
            {
                e.Handled = true;//经判断为数字,可以输入
            }
        }

        private void txb8_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
            {
                e.Handled = true;//经判断为数字,可以输入
            }
        }

        private void txb9_KeyPress(object sender, KeyPressEventArgs e)
        {

            if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
            {
                e.Handled = true;//经判断为数字,可以输入
            }
        }

        private void txb10_KeyPress(object sender, KeyPressEventArgs e)
        {

            if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
            {
                e.Handled = true;//经判断为数字,可以输入
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.listBox1.DataSource = Data();
            this.txb1.Text = "";
            this.txb2.Text = "";
            this.txb3.Text = "";
            this.txb4.Text = "";
            this.txb5.Text = "";
            this.txb6.Text = "";
            this.txb7.Text = "";
            this.txb8.Text = "";
            this.txb9.Text = "";
            this.txb10.Text = "";
            this.lb1.Text = "";
            this.lb2.Text = "";
            this.lb3.Text = "";
            this.lb4.Text = "";
            this.lb5.Text = "";
            this.lb6.Text = "";
            this.lb7.Text = "";
            this.lb8.Text = "";
            this.lb9.Text = "";
            this.lb10.Text = "";
            this.lbcr.Text = "正确率";
            this.lbtime.Text = "所用时间";

        }

        private void txb1_TextChanged(object sender, EventArgs e)
        {
            Frist = DateTime.Now;
        }
    }
}

   代码复审:刘晨龙

   

任务内容计划共完成需要的时间(min)实际完成需要的时间(min)
计划 30 40
开发 50 50
需求分析 (包括学习新技术) 30 30
· 生成设计文档 30 30
· 设计复审 (和同事审核设计文档) 30 30
代码规范 (为目前的开发制定合适的规范) 10 20
具体设计 20 30
具体编码 40 45
· 代码复审 30 30
· 测试(自我测试,修改代码,提交修改) 30 30
报告 30 30
· 测试报告 25 30
计算工作量 60 30
· 事后总结 ,并提出过程改进计划 10 10

个人总结:在这次编译中,用到的是动态绑定的10道随机数学题,然后数组记录结果,和用户输入的结果进行比较,然后得出对错和正确率。用的是获取焦点的办法来完成对事件的计时。本次不足的地方,布局不是很好。以后也可以在上面进行升级 ,来完成更高年级的数学题的运算。

推荐阅读