结队编程--基于GUI的四则运算
coding地址 https://git.coding.net/lizhiqiang0x01/GUI-sizeyunsuan.git
李志强 201421123028 连永刚 201421123014
一、题目要求:
1、除了整数之外,还要支持真分数的四则运算,真分数的运算,例如:1/6 + 1/8 = 7/24
2、运算符为 +, −, ×, ÷
3、并且要求能处理用户的输入,并判断错误,打分统计正确率
4、要求能处理用户输入的真分数,如 1/2, 5/12 等
5、程序基于GUI 界面
6、记录用户的对错总数,程序退出再启动的时候,能把以前的对错数量保存并在此基础上增量计算
7、有计时功能,能显示用户开始答题后的消耗时间
8、界面支持中文简体/中文繁体/英文,用户选择一种
二、实现步骤:
编写一个程序可在GUI 界面上可以进行中文简体/中文繁体/英文切换,对加减乘除运算优化升级和代码的重构,实现多级运算,在答题过程中需要计时并显示用户答题时间,在用户输入答案时,需要对输入的参数进行过滤,答题结束时用户可显示答题后的各种参数并实现可以查看错题库功能。
三、部分代码展示:
语言切换
private void radioButton2_CheckedChanged(object sender, EventArgs e) //切换成英文
{
this.label1.Text = "Please enter the subject number";
this.button1.Text = "start";
s.label8.Text = "Time";
s.label1.Text = "Schedule";
s.button1.Text = "NEXT";
this.Text = "English";
s.Text = "English";
} private void radioButton1_CheckedChanged(object sender, EventArgs e) //切换成中文简体
{
this.label1.Text = "请输入题目数(满分100)";
this.button1.Text = "开始做题";
s.label8.Text = "时间";
s.label1.Text = "题目进度";
s.button1.Text = "下一题";
this.Text = "中文";
s.Text = "中文";
} private void radioButton3_CheckedChanged(object sender, EventArgs e) //切换成中文繁体
{
this.label1.Text = "請輸入題目數(滿分100)";
this.button1.Text = "開始做題";
s.label8.Text = "時間";
s.label1.Text = "題目進度";
s.button1.Text = "下壹題";
this.Text = "中文繁體";
s.Text = "中文繁體";
}
检验答案
public void check()
{
int w = 1; for (int i = 2; i < 100; i++)
{
if (r1 % i == 0 && r2 % i == 0)
{
w = i;
}
}
r1 = r1 / w; r2 = r2 / w;
if (r2 < 0)
{
r2 = -r2;
r1 = -r1;
}
ai = StringClear(this.textBox1.Text);
if (cro != 1)
{
if (r2 == 1)
au = this.r1.ToString();
if (r2 != 1)
au = r1 + "/" + r2;
if (ai == au)
{
n1++;
}
if (ai != au)
{
FileStream f = new FileStream("cuoti.txt", FileMode.Append, FileAccess.Write);
StreamWriter fi = new StreamWriter(f);
fs = "你的答案:" + this.label12.Text + this.label13.Text + this.label14.Text + this.label2.Text + this.label4.Text + this.label5.Text + this.label15.Text + this.label9.Text + ai + " 正确答案:" + au + " " + "\r\n";
fi.Write(fs);
fi.Flush();
fi.Close();
f.Close();
if (this.Text == "中文")
{
MessageBox.Show("回答错误!正确答案:" + au);
}
else if (this.Text == "English")
{
MessageBox.Show("Wrong answer!The correct answer:" + au);
}
else
{
MessageBox.Show("回答錯誤!正確答案:" + au);
}
}
}
}
多级运算
public void select()
{
int l1, l2;
Random ra = new Random();
int x = ra.Next(0, 4);
switch (x)
{
case 0: add(); break;
case 1: sub(); break;
case 2: mul(); break;
case 3: div(); break;
}
int y = ra.Next(0, 5);
switch (y)
{
case 0:
if (q6 == 1) this.label12.Text = q5.ToString();
else this.label12.Text = q5 + "/" + q6;
this.label13.Text = "+";
this.label14.Text = "";
this.label15.Text = "";
l1 = r1;l2=r2;
r1 = l1 * q6 + l2 * q5;
r2 = l2 * q6;
break;
case 1:
if (q6 == 1) this.label12.Text = q5.ToString();
else this.label12.Text = q5 + "/" + q6;
this.label13.Text = "-";
this.label14.Text = "(";
this.label15.Text = ")";
l1 = r1;l2=r2;
r1 = l1 * q5 - l2 * q6;
r2 = l2 * q6;
break;
case 2:
if (q6 == 1) this.label12.Text = q5.ToString();
else this.label12.Text = q5 + "/" + q6;
this.label13.Text = "×";
this.label14.Text = "(";
this.label15.Text = ")";
l1 = r1;l2=r2;
r1 = l1 * q5;
r2 = l2 * q6;
break;
case 3:
if (q6 == 1) this.label12.Text = q5.ToString();
else this.label12.Text = q5 + "/" + q6;
this.label13.Text = "÷";
this.label14.Text = "(";
this.label15.Text = ")";
l1 = r1;l2=r2;
this.r1 = this.q5 * l2;
this.r2 = this.q6 * l1;
break;
case 4:
this.label12.Text = "";
this.label13.Text = "";
this.label14.Text = "";
this.label15.Text = "";
break;
}
}
过滤非法字符
public string StringClear(string ai)
{
bool temp = bolnum(ai);
if (temp == true)
{
return ai;
}
else
{
cro = 1;
if (this.Text == "中文")
{
MessageBox.Show("输入错误,请正确输入字符!例如:12,1/2");
}
else if (this.Text == "English")
{
MessageBox.Show("Input error, please correct input character! For example:12,1/2");
}
else
{
MessageBox.Show("輸入錯誤,請正確輸入字符!例如:12,1/2");
}
this.textBox1.Text = "";
return "";
}
} public bool bolnum(string temp) //若为非法字符,返回false
{
for (int i = 0; i < temp.Length; i++)
{
byte tempByte = Convert.ToByte(temp[i]);
if ((tempByte > 46) && (tempByte < 58))
return true;
}
return false;
}
功能展示

四、PSP:
| PSP2.1 | Personal Software Process Stages | Estimated time(h) | actual time(h) |
| Planning | 计划 | 1 | 1.5 |
| · Estimate | 估计这个任务需要多少时间 | 24 | 40 |
| Development | 开发 | 24 | 34 |
| · Analysis | 需求分析 (包括学习新技术) | 1 | 1.2 |
| · Design Spec | 生成设计文档 | 7 | 10 |
| · Design Review | 设计复审 | 0.5 | 0.5 |
| · Coding Standard | 代码规范 | 0.5 | 0.8 |
| · Design | 具体设计 | 1.5 | 1.5 |
| · Coding | 具体编码 | 20 | 30 |
| · Code Review | 代码复审 | 10 | 15 |
| · Test | 测试(自我测试,修改代码,提交修改) | 1 | 3 |
| Reporting | 报告 | 20 | 25 |
| · | 测试报告 | 1 | 1.5 |
| · | 计算工作量 | 0.5 | 1 |
| · | 并提出过程改进计划 | 2 | 4 |
五、总结:
通过这几天的共同努力,从此次的项目中收货颇多,学习别人的长处从而发现自己的短板,同时对于自己很不擅长的GUI从中也学习到了很多知识。
q1.期间在实现加减乘除多级运算功能时,由于没有对变量的规范化,使得在引用变量中造成混淆出现BUG
定义新的变量使问题得以解决

q2.由于在校验过程中,忽视了负号会出现在分母中这种情况,在检查函数中添加
使得问题迎刃而解
我们发现问题,找出问题,共同解决问题

结队编程--基于GUI的四则运算的更多相关文章
- 结队编程-基于gui的四则运算生成器
成员:卢少锐 201421123027.刘存201421033023 coding.net地址 1.需求分析:除了实现四则运算的功能外,还添加了计时器功能和语言选择功能 2.程序设计:这次作业是基于上 ...
- 基于GUI的四则运算
基于GUI的四则运算 李志强 201421123028 连永刚 201421123014 林方言 201421123023 coding 地址 https://git.coding.net/lizhi ...
- 结对作业--基于GUI的四则运算生成器
组员:201421123015 陈麟凤 201421123019 张志杰 201421123020 黄海鸿 coding 地址 :https://coding.net/u/zhang1995/p/wo ...
- 结对作业(1)----基于GUI的四则运算
小伙伴:201421123031 余洋 201421123044 潘志坚 题目要求: 我们在个人作业1中,用各种语言实现了一个命令行的四则运算小程序.进一步,本次要求把这个程序做成GUI(可以是W ...
- 结对作业:基于GUI实现四则运算
1)Coding.Net项目地址:https://git.coding.net/day_light/GUIszysLL.git 2)在开始实现程序之前,在下述PSP表格记录下你估计将在程序的各个模块的 ...
- 结对实验---基于GUI的四则运算
详细代码:https://git.coding.net/wangluo24/NO.2.git 结对伙伴:吕志哲(201421123021) &本人.许明涛 201421123024 一.题目要 ...
- 结对作业-基于GUI的四则运算
一.需求分析 1.题目要求: 我们在个人作业1中,用各种语言实现了一个命令行的四则运算小程序.进一步,本次要求把这个程序做成GUI(可以是Windows PC 上的,也可以是Mac.Linux,web ...
- 结对编程1 (四则运算基于GUI)
https://git.coding.net/Luo_yujie/sizeyunsuan.app.git 201421123034 201421123032 1. 需求分析 这次作业新引用了语言选择, ...
- 20175126Apollo 20175126《Java程序设计》结队编程项目——四则运算
结队编程项目——四则运算 一.项目需求 自动生成小学四则运算题目(加.减.乘.除)统计正确率 支持整数 支持多运算符(比如生成包含100个运算符的题目) 支持真分数 需求分析: 生成四则运算:需要使用 ...
随机推荐
- 使用我的编译器,下面的代码 int i=7; printf("%d\n", i++ * i++); 返回 49?不管按什么顺序计算, 难道不该打印出56吗?
尽管后缀自加和后缀自减操作符 ++ 和 -- 在输出其旧值之后才会执行运算, 但这里的"之后"常常被误解.没有任何保证确保自增或自减会在输出变量原值之 后和对表达式的其它部分进行计 ...
- web端常见安全漏洞测试结果分析-- appscan
基于appscan测试结果分析: 一.XSS跨站脚本 指的是攻击者往Web页面里插入恶意html代码,通常是JavaScript编写的恶意代码,当用户浏览该页之时,嵌入其中Web里面的html代码会被 ...
- asp.net 程序,当发生找不到文件的错误时,如何正确定位是哪个文件?
需要在Global.asax.cs中添加Application_Error代码如下,在Log中查看是哪个文件缺失: protected void Application_Error(object se ...
- TensorFlow学习笔记2——数据类型及简单运算
0. 小试牛刀 首先,激活tensorflow环境( source activate tensorflow ),随后在ipython里: import tensorflow as tf sess = ...
- angular或者js如何确定选中ul中的哪几个li
刚来新公司接到新的需求做一个知识库页面 红色的是单选 蓝色的是多选 这些都是需要传递到后台的 开始不知道如何解决 下班后在家想到一个很巧妙的办法 不多说上代码 箭头所指就是在li里写 ...
- Python requests 安装与开发
Requests 是用Python语言编写HTTP客户端库,跟urllib.urllib2类似,基于 urllib,但比 urllib 更加方便,可以节约我们大量的工作,完全满足 HTTP 测试需求, ...
- django开发者模式中的autoreload是怎样实现的
在开发django应用的过程中,使用开发者模式启动服务是特别方便的一件事,只需要 python manage.py runserver 就可以运行服务,并且提供了非常人性化的autoreload机制, ...
- [C#] out vs ref
当需要从一个方法中有多个返回值时可以考虑使用out和ref这两个关键字.下面通过代码的方式来说明两者的用法和不同之处. 例如现在有一个如下的Add方法,Add方法只有一个返回值. static int ...
- master log 与relay log的关系
--master log 与relay log的关系 -------------------------------2014/06/09 Just to clarify, there are thre ...
- 关于web.xml中的<welcome-file-list>
关于web.xml中的<welcome-file-listgt; WebXMLSpringJSPTomcat 问题: <welcome-file-listgt;中的<welcome- ...