文章目录
一、pandas是什么?
编写一个Windows程序,实现自动出题并判分的功能。
功能要求:
能使用Random类随机出加减法的题目(2分)
能使用if/switch进行答案的判断(2分)
能使用事件处理,当用户答案填正确时,界面上有反馈(如文本框背景颜色的改变)(2分)
能使用Timer控件,自动发出事件,如自动出题(2分)
其他扩充功能(选做),如难题的判断,得分的计算等等(2分)。
二、效果演示
三、代码
Form1.cs
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;
using System.Threading;
namespace Calculater
{
/**
* C#口算训练程序
*/
public partial class Form1 : Form
{
int sec = 0; // 计时数字
int score = 0; // 分数
int first; // 第一个数字
int second; // 第二个数字
int speed = 3000; // 自动显示间隔
bool isOn = false; //开始标记
int mode = 1; // 题目类型编号,1代表10以内加减法,2代表20以内加减法,3代表10以内乘法
public Form1()
{
InitializeComponent();
}
/**
* 开始按钮被点击
*/
private void btn_next_Click(object sender, EventArgs e)
{
text_result.Text = null;
text_result.Enabled = true;
text_result.Focus();
lab_time.Enabled = true;
// 题目计时开始
timer1.Start();
// 自动显示下一题计时开始
if (checkBox1.Checked)
{
timer2.Start();
}
// 开始后复选框禁用
checkBox1.Enabled = false;
checkBox2.Enabled = false;
if (isOn)
{
start();
}
else
{
isOn = true;
btn_next.Text = "下一题";
btn_next.Width = 50;
btn_stop.Visible = true;
return;
}
}
/**
* 结束按钮被点击
*/
private void btn_stop_Click(object sender, EventArgs e)