其他分享
首页 > 其他分享> > 小学生计算题卡(重置版)

小学生计算题卡(重置版)

作者:互联网

计应192(西)—第三组—黄如意

  思路:

  用一个列表让用户选择加减乘除运算,生成两个随机数与运算符结合形成算式,用户输入结果后提交,系统做出判断并展示在listBox1中,listBox1中展示用户做题的记录以及对错,右侧则展示用户正确的题数,点击重新答题则会清空listBox1中的历史记录和用户正确题数

    UI展示:

  

    后置代码: 

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 小学生计算题卡
{
public partial class Form1 : Form
{
Random random = new Random();
public int 操作数1;
public int 操作数2;
public int 正确数量;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
czs1.Text = "操作数1";
czs2.Text = "操作数2";
xzysf.SelectedIndex = 0;
jg.Text = "";
listBox1.Items.Clear();
jg.Focus();
}

private void sc_Click(object sender, EventArgs e)
{
ysf.Text = (string)xzysf.SelectedItem;
操作数1 = random.Next(1, 100);
操作数2 = random.Next(1, 100);
czs1.Text = 操作数1.ToString();
czs2.Text = 操作数2.ToString();
}

private void ysf_Click(object sender, EventArgs e)
{

}

private void Form1_Load(object sender, EventArgs e)
{
xzysf.SelectedIndex = 0;
jg.Focus();
}

private void tj_Click(object sender, EventArgs e)
{

string a = czs1.Text;
string b = czs2.Text;
string c = jg.Text;
if (jg.Text == "")
{
MessageBox.Show("请输入结果后再进行提交!");
}
else if (ysf.Text == "+")
{
if (int.Parse(a) + int.Parse(b) == int.Parse(c))
{

listBox1.Items.Add(a + "+" + b + "=" + c + " " + "回答正确!");
正确数量++;
}
else
{
listBox1.Items.Add(a + "+" + b + "=" + c + " " + "回答错误!");
}

}
else if (ysf.Text == "-")
{
if (int.Parse(a) - int.Parse(b) == int.Parse(c))
{

listBox1.Items.Add(a + "-" + b + "=" + c + " " + "回答正确!");
正确数量++;
}
else
{
listBox1.Items.Add(a + "-" + b + "=" + c + " " + "回答错误!");
}

}
else if (ysf.Text == "×")
{
if (int.Parse(a) * int.Parse(b) == int.Parse(c))
{

listBox1.Items.Add(a + "×" + b + "=" + c + " " + "回答正确!");
正确数量++;
}
else
{
listBox1.Items.Add(a + "×" + b + "=" + c + " " + "回答错误!");
}
}
else if (ysf.Text == "÷")
{
if (double.Parse(a) / double.Parse(b) == double.Parse(c))
{
listBox1.Items.Add(a + "÷" + b + "=" + c + " " + "回答正确!");
正确数量++;
}
else
{
listBox1.Items.Add(a + "÷" + b + "=" + c + " " + "回答错误!");
}
}
zql.Text = 正确数量.ToString();
jg.Text = "";
jg.Focus();
}

private void czs1_Click(object sender, EventArgs e)
{

}

private void button1_Click_1(object sender, EventArgs e)
{
}

private void label6_Click(object sender, EventArgs e)
{

}

private void timer1_Tick(object sender, EventArgs e)
{
}
}
}

  运行展示:

 

  PSP:

 

报告

测试报告:基本功能(+,-,*,/)都能实现,而且用户可以自选运算法则,但功能比较单一,只能处理两个数,而且不能调整难度。

计算工作量:这个计算题卡设计并不大,但因为我使用winfrom写代码较少,排版和寻找控件及对应属性,事件花了大量时间。

事后总结:基本能满足要求,但无法设置难度,会导致用户的不良体验。一些细节仍待改善!

标签:计算题,int,Text,void,重置,Parse,listBox1,using,小学生
来源: https://www.cnblogs.com/yiyeguhong/p/14832853.html