数学测试 计应192(西) 李明戈 第三组

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

int a, b,aaa,bbb,bb;

string op;
string op1;
string op2;

int result;
int result1;
int result2;


Random rnd = new Random();

private void Form1_Load(object sender, EventArgs e)
{


}


private void Button1Click(object sender, EventArgs e)
{

a = rnd.Next(10) + 1;

b = rnd.Next(10) + 1;
if (a<=b)
a=a+b;


aaa = rnd.Next(10) + 1;

bbb = rnd.Next(10) + 1;
if (aaa<=bbb)
aaa=aaa+bbb;
bb = rnd.Next(8) + 1;
int c = rnd.Next(3);
int cc = rnd.Next(3);
int ccc = rnd.Next(2);
switch (c)

{

case 0: op = "+"; result = a + b; break;

case 1: op = "-"; result = a - b; break;

case 2: op = "×"; result = a * b; break;

case 3: op = "÷"; result = a / b; break;

}
switch (cc)

{

case 0: op1 = "+"; result1 = aaa + bbb ; break;//OP1表示当前运算符号和结果,运算结果result1等于加数+加数

case 1: op1 = "-"; result1 = aaa - bbb ; break;//OP1表示当前运算符号和结果,运算结果result1等于被减数-减数

case 2: op1 = "×"; result1 = aaa * bbb ; break;//OP1表示当前运算符号和结果,运算结果result1等于乘数*乘数

case 3: op1 = "÷"; result1 = aaa / bbb ; break;//OP1表示当前运算符号和结果,运算结果result1等于除数/除数

}
switch (ccc)

{

case 0: op2 = "+"; result2 = result1 + bb; break;

 

case 1: op2 = "×"; result2 = result1 * bb; break;

 

}

textBox2.Text = a.ToString();//算式1中的从左边到右第一个数

textBox3.Text = b.ToString();//算式1中的从左边到右第二个数

textBox4.Text = aaa.ToString();//算式2中的从左边到右第一个数

textBox5.Text = bbb.ToString();//算式2中的从左边到右第二个数
textBox6.Text = bb.ToString();//算式2中的从左边到右第三个数

label2.Text = op;//算式1中的运算符号,随机产生对应的符号
label1.Text = op1;//算式2中的运算符号,随机产生对应的符号
label6.Text = op2;//算式2中的运算符号,随机产生对应的符号
textBox1.Text="";//按键后清空文本框的内容!
textBox7.Text="";//按键后清空文本框的内容!
textBox1.Focus();

}

private void Button2Click(object sender, EventArgs e)
{

//if (textBox1.Text =="")
// MessageBox.Show("请输入数字,不能为空");

//else
// MessageBox.Show("输入的数字正确");


if (textBox1.Text == "")//判断是否输入的用户名,如果没有输入,显示下面的提示,否则跳到else
{
MessageBox.Show("答案不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
if (textBox7.Text == "")//判断是否输入的用户名,如果没有输入,显示下面的提示,否则跳到else
{
MessageBox.Show("答案不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
string str = textBox1.Text;//文本框输入为等式的结果,结果答案输入处。

string str1 = textBox7.Text;

double d = double.Parse(str);

double dd = double.Parse(str1);
string disp = " " + a + op + b + "=" + str + " ";
string disp1 = " " + aaa + op1 + bbb + op2 + bb + "=" + str1 + " ";



if (d == result) // if( Math.Abs(d-result)< 1e-3 )


disp += "√ 答案正确 刘颖颖你真棒";

else

disp += "╳ 答案错误 加油重新列算式运算";
if (dd == result2) // if( Math.Abs(d-result)< 1e-3 )

disp1 += "√ 答案正确 刘颖颖你真棒";

else
disp1 += "╳ 答案错误 加油重新列算式运算";

lstDisp.Items.Add(disp);
lstDisp.Items.Add(disp1);
textBox1.Text="";//清空上一次输入的结果!
textBox7.Text="";//清空上一次输入的结果!

}

}
void TextBox1KeyPress(object sender, KeyPressEventArgs e)
{
if(!(char.IsNumber(e.KeyChar))&& e.KeyChar !=(char)8)
{
e.Handled = true;//判定为数字,可以输入
}
}
void LstDispSelectedIndexChanged(object sender, EventArgs e)
{
if (lstDisp.Text.Length >10)
lstDisp.Text = "";
}
void TextBox7KeyPress(object sender, KeyPressEventArgs e)
{
if(!(char.IsNumber(e.KeyChar))&& e.KeyChar !=(char)8)
{
e.Handled = true;//判定为数字,可以输入
}
}
void Button3Click(object sender, EventArgs e)
{
lstDisp.Items.Clear();
}

}

 

psp 阶段 花费时间
计划
明确需求和其他元素,估计每个阶段的成本时间                                                     一共3小时 
开发                                                                                                                            共花了130分钟
需求分析                                                                                                                     30分钟
生成设计文档                                                                                                              10分钟
设计复审(和同伴一起)                                                                                              5分钟
代码规范(为开发制定合适的规范)                                                                         30分钟
具体设计                                                                                                                         30
具体代码                                                                                                                         35
代码复审                                                                                                                        5分钟
测试(单元测试)                                                                                                         10分钟
报告 花了半小时左右
测试报告                                                                                                                            30分钟
计算工作量                                                                                                                  50行有效代码
时事后总结,提出计划                                                                                                  5分钟

posted @ 2021-04-11 16:11  计应192西三组  阅读(45)  评论(0编辑  收藏  举报