团队名:QS
结对成员:张子腾 赵必瑞
作业要求:
第一阶段结对作业验收小学生四则运算
提交内容包括:
可以运行的程序或安装包;源程序代码;软件使用说明书;结对成员简介和分工说明;程序代码:
public partial class Form1 : Form
{ public Form1() { InitializeComponent(); } List<string> question = new List<string>();//题目数组 List<int> chongfu = new List<int>();//在筛选题目时用来判断是否选过该题目 int[] a1 = new int[400]; int[] a2 = new int[400]; int num = 0,a = 0,k = 0,k1 = 0;//num为选择的题量 a为选择的符号的个数 k为筛选题目时筛选出的题号 k1用来记录上一提的题号以便加入错题 int t = 0, f = 0;//t为正确的题数 f为错误的题数 int jia = 0, jian = 0, cheng = 0, chu = 0;//用来判断符号 int ti = 0;//当前题数 int m = 0,n = 0;//m用来判断是错题重测还是做新题 n用来 Random ra = new Random();//随机生成数字 List<string> mark = new List<string>();//错题库 List<int> marka1 = new List<int>();//第一个数 List<int> marka2 = new List<int>();//第二个数 List<int> af = new List<int>();//符号数组 string markpath = @"D:\vsform\math\mark.txt";//错题库及路径 string fuhaopath = @"D:\vsform\math\af.txt";//错题符号路径 string mark1path = @"D:\vsform\math\markti.txt";//错题题数路径 string marka1path = @"D:\vsform\math\marka1.txt";//错题第一个数路径 string marka2path = @"D:\vsform\math\marka2.txt";//错题第二个数路径private void button3_Click(object sender, EventArgs e)//添加错题
{ mark.Add(question[k1]); marka1.Add(a1[k1]); marka2.Add(a2[k1]); StreamWriter marktxt = new StreamWriter(markpath,true); StreamWriter ma1 = new StreamWriter(marka1path, true); StreamWriter ma2 = new StreamWriter(marka2path, true); marktxt.WriteLine(question[k1]); ma1.WriteLine(a1[k1]); ma2.WriteLine(a2[k1]); StreamWriter fuhao = new StreamWriter(fuhaopath,true); if (k >= 0 && k <= num * (a - jian - cheng - chu) - 1) { af.Add(1); fuhao.WriteLine("1"); } if (k >= num * jia && k <= num * (a - cheng - chu) - 1) { af.Add(2); fuhao.WriteLine("2"); } if (k >= num * (jia + jian) && k <= num * (a - chu) - 1) { af.Add(3); fuhao.WriteLine("3"); } if (k >= num * (jia + jian + cheng) && k <= num * a - 1) { af.Add(4); fuhao.WriteLine("4"); } marktxt.Close(); ma1.Close(); ma2.Close(); fuhao.Close(); }private void button4_Click(object sender, EventArgs e)//返回同时重置
{ a1 = new int[400]; a2 = new int[400]; listBox1.Items.Clear(); listBox1.Items.Remove("得分:" + ((double)t / (double)num * 100).ToString() + " 错题数:" + f.ToString()); num = 0; a = 0; k = 0; t = 0; f = 0; jia = 0; jian = 0; cheng = 0; chu = 0; ti = 0; chongfu.Clear(); question.Clear(); button1.Visible = true; label1.Visible = true; radioButton1.Visible = true; radioButton2.Visible = true; radioButton3.Visible = true; radioButton4.Visible = true; checkBox1.Visible = true; checkBox2.Visible = true; checkBox3.Visible = true; checkBox4.Visible = true; label4.Visible = false; textBox1.Visible = false; button2.Visible = false; listBox1.Visible = false; button5.Visible = true; button3.Visible = false; button4.Visible = false; panel4.Visible = false; button2.Enabled = true; label5.Visible = true; button3.Text = "添加上题至错题"; if (m != 1) { StreamReader mark1 = new StreamReader(mark1path); n = int.Parse(mark1.ReadLine()) + mark.Count; mark1.Close(); StreamWriter marktxt = new StreamWriter(mark1path, false); marktxt.WriteLine(n); marktxt.Close(); label5.Text = "错题本中已有" + "\n" + n.ToString() + "题"; } mark.Clear(); af.Clear(); marka1.Clear(); marka2.Clear(); m = 0; }private void button5_Click(object sender, EventArgs e)//错题重置
{ button1.Visible = false; label1.Visible = false; radioButton1.Visible = false; radioButton2.Visible = false; radioButton3.Visible = false; radioButton4.Visible = false; checkBox1.Visible = false; checkBox2.Visible = false; checkBox3.Visible = false; checkBox4.Visible = false; label4.Visible = true; textBox1.Visible = true; button2.Visible = true; listBox1.Visible = true; panel4.Visible = true; button4.Visible = true; button5.Visible = false; label5.Visible = false; m++; if (n == 0) { MessageBox.Show("错题本中尚没有错题", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { StreamReader marktxt = new StreamReader(markpath); marktxt.ReadLine(); mark.Add(marktxt.ReadLine()); label4.Text = mark[0]; marktxt.Close(); } }private void button1_Click(object sender, EventArgs e)//题库筛选并转到做题页面
{ if (radioButton1.Checked) { num = 20; judge1(); } if (radioButton2.Checked) { num = 40; judge1(); } if (radioButton3.Checked) { num = 50; judge1(); } if (radioButton4.Checked) { num = 100; judge1(); } k = ra.Next(0, num * a); try { label4.Text = question[k]; } catch { MessageBox.Show("请正确进行选择!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Information); } chongfu.Add(k); button1.Visible = false; label1.Visible = false; radioButton1.Visible = false; radioButton2.Visible = false; radioButton3.Visible = false; radioButton4.Visible = false; checkBox1.Visible = false; checkBox2.Visible = false; checkBox3.Visible = false; checkBox4.Visible = false; button5.Visible = false; label5.Visible = false; label4.Visible = true; textBox1.Visible = true; button2.Visible = true; listBox1.Visible = true; button3.Visible = true; button4.Visible = true; panel4.Visible = true; }private void Form1_Load(object sender, EventArgs e)
{ label4.Visible = false; textBox1.Visible = false; button2.Visible = false; listBox1.Visible = false; button3.Visible = false; button4.Visible = false; panel4.Visible = false; StreamReader marktxt = new StreamReader(mark1path);//对错题进行读取 n = int.Parse(marktxt.ReadLine()); label5.Text = "错题本中已有" + "\n" + n.ToString() + "题"; marktxt.Close(); }private void button2_Click(object sender, EventArgs e)//确认答案并显示下一题
{ int panduan = 0;//用来判断textbox中数字的格式是否正确 textBox1.Focus(); try { int a = int.Parse(textBox1.Text); } catch { MessageBox.Show("请输入整数", "注意!", MessageBoxButtons.OK, MessageBoxIcon.Warning); panduan = 1; } if (panduan == 0) { if (m == 1) { StreamReader marktxt = new StreamReader(markpath); StreamReader fuhao = new StreamReader(fuhaopath); StreamReader ma1 = new StreamReader(marka1path); StreamReader ma2 = new StreamReader(marka2path); for (int i = 0; i <= ti; i++) { fuhao.ReadLine(); ma1.ReadLine(); ma2.ReadLine(); } af.Add(int.Parse(fuhao.ReadLine())); marka1.Add(int.Parse(ma1.ReadLine())); marka2.Add(int.Parse(ma2.ReadLine())); ma1.Close(); ma2.Close(); fuhao.Close(); if (af[ti] == 1) { if (marka1[ti] + marka2[ti] == int.Parse(textBox1.Text)) { listBox1.Items.Add(mark[ti] + textBox1.Text + " " + "√"); t++; } else { listBox1.Items.Add(mark[ti] + textBox1.Text + " " + "× " + "正确答案:" + (marka1[ti] + marka2[ti]).ToString()); f++; } } if (af[ti] == 2) { if (marka1[ti] == int.Parse(textBox1.Text)) { listBox1.Items.Add(mark[ti] + textBox1.Text + " " + "√"); t++; } else { listBox1.Items.Add(mark[ti] + textBox1.Text + " " + "× " + "正确答案:" + marka1[ti].ToString()); f++; } } if (af[ti] == 3) { if (marka1[ti] * marka2[ti] == int.Parse(textBox1.Text)) { listBox1.Items.Add(mark[ti] + textBox1.Text + " " + "√"); t++; } else { listBox1.Items.Add(mark[ti] + textBox1.Text + " " + "× " + "正确答案:" + (marka1[ti] * marka2[ti]).ToString()); f++; } } if (af[ti] == 4) { if (marka1[ti] == int.Parse(textBox1.Text)) { listBox1.Items.Add(mark[ti] + textBox1.Text + " " + "√"); t++; } else { listBox1.Items.Add(mark[ti] + textBox1.Text + " " + "× " + "正确答案:" + marka1[ti].ToString()); f++; } } listBox1.SelectedIndex = listBox1.Items.Count - 1; listBox1.SelectedIndex = -1; ti++; for (int i = 0; i <= ti; i++) { marktxt.ReadLine(); } mark.Add(marktxt.ReadLine()); marktxt.Close();if (ti == n)
{ listBox1.Items.Add("得分:" + ((double)t / (double)n * 100).ToString() + " 错题数:" + f.ToString()); label4.Text = "已无错题"; button2.Enabled = false; } label4.Text = mark[ti]; } else { if (k >= 0 && k <= num * (a - jian - cheng - chu) - 1) { if (a1[k] + a2[k] == int.Parse(textBox1.Text)) { listBox1.Items.Add(question[k] + textBox1.Text + " " + "√"); t++; } else { listBox1.Items.Add(question[k] + textBox1.Text + " " + "× " + "正确答案:" + (a1[k] * a2[k]).ToString()); f++; } } if (k >= num * jia && k <= num * (a - cheng - chu) - 1) { if (a1[k] == int.Parse(textBox1.Text)) { listBox1.Items.Add(question[k] + textBox1.Text + " " + "√"); t++; } else { listBox1.Items.Add(question[k] + textBox1.Text + " " + "× " + "正确答案:" + a1[k].ToString()); f++; } } if (k >= num * (jia + jian) && k <= num * (a - chu) - 1) { if (a1[k] * a2[k] == int.Parse(textBox1.Text)) { listBox1.Items.Add(question[k] + textBox1.Text + " " + "√"); t++; } else { listBox1.Items.Add(question[k] + textBox1.Text + " " + "× " + "正确答案:" + (a1[k] * a2[k]).ToString()); f++; } } if (k >= num * (jia + jian + cheng) && k <= num * a - 1) { if (a1[k] == int.Parse(textBox1.Text)) { listBox1.Items.Add(question[k] + textBox1.Text + " " + "√"); t++; } else { listBox1.Items.Add(question[k] + textBox1.Text + " " + "× " + "正确答案:" + a1[k].ToString()); f++; } } listBox1.SelectedIndex = listBox1.Items.Count - 1; listBox1.SelectedIndex = -1; ti++; if (ti == num) { listBox1.Items.Add("得分:" + ((double)t / (double)num * 100).ToString() + " 错题数:" + f.ToString()); button2.Enabled = false; button3.Text = "添加本题至错题"; } k1 = k; if (ti != num) { while (chongfu.Contains(k)) { k = ra.Next(0, num * a); } label4.Text = question[k]; if (!chongfu.Contains(k)) { chongfu.Add(k); } } } } textBox1.Text = ""; }public void judge1()//生成题库
{if (radioButton5.Checked)//10以内
{ if (checkBox1.Checked)//加法 { jia++; a++; int i = 0; while (i <= num - 1) { a1[i + num * (a - 1)] = ra.Next(10); a2[i + num * (a - 1)] = ra.Next(10); string s = a1[i + num * (a - 1)].ToString() + "+" + a2[i + num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } if (checkBox2.Checked)//减法 { jian++; a++; int i = 0; while (i <= num - 1) { a1[i + num * (a - 1)] = ra.Next(10); a2[i + num * (a - 1)] = ra.Next(10- a1[i + num * (a - 1)]); string s = (a1[i + num * (a - 1)] + a2[i + num * (a - 1)]).ToString() + "-" + a2[i + num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } if (checkBox3.Checked)//乘法 { cheng++; a++; int i = 0; while (i <= num - 1) { a1[i + num * (a - 1)] = ra.Next(10); a2[i + num * (a - 1)] = ra.Next(10); string s = a1[i + num * (a - 1)].ToString() + "*" + a2[i + num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } if (checkBox4.Checked)//除法 { chu++; a++; int i = 0; while (i <= num - 1) { a1[i + num * (a - 1)] = ra.Next(1,10/2); a2[i + num * (a - 1)] = ra.Next(2,10 / a1[i + num * (a - 1)]); string s = (a1[i + num * (a - 1)]* a2[i + num * (a - 1)]).ToString() + "÷" + a2[i + num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } } if (radioButton6.Checked)//100以内 { if (checkBox1.Checked)//加法 { jia++; a++; int i = 0; while (i <= num - 1) { a1[i+ num * (a - 1)] = ra.Next(100); a2[i+ num * (a - 1)] = ra.Next(100); string s = a1[i+ num * (a - 1)].ToString() + "+" + a2[i+ num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } if (checkBox2.Checked)//减法 { jian++; a++; int i = 0; while (i <= num - 1) { a1[i + num * (a - 1)] = ra.Next(100); a2[i + num * (a - 1)] = ra.Next(100 - a1[i + num * (a - 1)]); string s = (a1[i + num * (a - 1)] + a2[i + num * (a - 1)]).ToString() + "-" + a2[i + num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } if (checkBox3.Checked)//乘法 { cheng++; a++; int i = 0; while (i <= num - 1) { a1[i + num * (a - 1)] = ra.Next(100); a2[i + num * (a - 1)] = ra.Next(100); string s = a1[i + num * (a - 1)].ToString() + "*" + a2[i+num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } if (checkBox4.Checked)//除法 { chu++; a++; int i = 0; while (i <= num - 1) { a1[i + num * (a - 1)] = ra.Next(1,100/2); a2[i + num * (a - 1)] = ra.Next(2,100/a1[i+ num * (a - 1)]); string s = (a1[i + num * (a - 1)]* a2[i + num * (a - 1)]).ToString() + "÷" + a2[i + num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } } if (radioButton7.Checked)//1000以内 { if (checkBox1.Checked)//加法 { jia++; a++; int i = 0; while (i <= num - 1) { a1[i + num * (a - 1)] = ra.Next(1000); a2[i + num * (a - 1)] = ra.Next(1000); string s = a1[i + num * (a - 1)].ToString() + "+" + a2[i + num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } if (checkBox2.Checked)//减法 { jian++; a++; int i = 0; while (i <= num - 1) { a1[i + num * (a - 1)] = ra.Next(1000); a2[i + num * (a - 1)] = ra.Next(1000 - a1[i + num * (a - 1)]); string s = (a1[i + num * (a - 1)] + a2[i + num * (a - 1)]).ToString() + "-" + a2[i + num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } if (checkBox3.Checked)//乘法 { cheng++; a++; int i = 0; while (i <= num - 1) { a1[i + num * (a - 1)] = ra.Next(1000); a2[i + num * (a - 1)] = ra.Next(1000); string s = a1[i + num * (a - 1)].ToString() + "*" + a2[i + num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } if (checkBox4.Checked)//除法 { chu++; a++; int i = 0; while (i <= num - 1) { a1[i + num * (a - 1)] = ra.Next(1,1000/2); a2[i + num * (a - 1)] = ra.Next(2,1000 / a1[i + num * (a - 1)]); string s = (a1[i + num * (a - 1)]* a2[i + num * (a - 1)]).ToString() + "÷" + a2[i + num * (a - 1)].ToString() + "="; if (!question.Contains(s)) { question.Add(s); i++; } else { continue; } } } } }}
}使用说明:
用户能够选择做题的数量,难度,类型。当用户做题时,能够看到问题和自己输入的答案,当确定答案后,系统能够判断答案正误,将错误予以纠正并显示用户可以将自己刚做错的题有选择的储存起来。当程序关闭后,错题会被保存进计算机,程序再一次启动时可以直接读取错题。
使用时先打开程序,任选一种难度,若干种类型,一种题量进行作答,作答过程中任意挑选若干题目加入错题,完整地完成一次测试,观察程序是否正常运行。返回后进行错题重测,完整地进行一次错题重测,观察程序是否正常运行。分工:
张子腾:设计程序思路,编写代码程序赵必瑞:程序代码复审和代码运行测试合作:一起对程序进行封装,一起运用VS来进行软件系统的设计