第二次作业

git地址:https://github.com/zbwsl

git用户名:zbwsl

学号后五位:62421

博客地址:https://www.cnblogs.com/zbwsl/

作业链接:https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass2/homework/2795

配置环境:这是vs2017,之前已经配置过了,就没演示了

 

克隆项目

1.拷贝:

  • 成功登录后,输入阿超仓库的网址https://github.com/YuRenDaZ/AchaoCalculator(这个为我们班级所指定的仓库地址),点击右上角的 Fork ,
  • 将阿超的四则运算库拷贝到自己的同名仓库中,如下图所示: 

2.git bash:克隆下来后,右键单击这个文件,打开git bash;输入即可克隆

3.这是克隆下来的文件

 

 这里建立了一个项目,就是下面的代码项目,在克隆的文件里

 4.

 

3.项目设计

 随机出n道100以内的运算符在2~3个的加减乘除练习题

我只写了三个数的加减乘除,下面就是代码和运行截图;用的方法比较基础;

下面是项目代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
class Program
{
static Random rd = new Random();
static int data()
{
int da = rd.Next(0, 100);
return da;
}
static char zf()
{
char[] a = new char[] { '+', '-', '*', '/' };
int i = rd.Next(0, 4) % 4;
return a[i];
}
static void Main(string[] args)
{
int a, c, e;
char b, d;
int sum = 0;
Console.WriteLine("需要打印的练习题个数:");
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
a = data();
b = zf();
c = data();
d = zf();
e = data();
if ('/' == b)
{
if (0 == c)
{
n = n + 1;
continue;
}
else if (a / c != (float)a / (float)c)
{
n = n + 1;
continue;
}
}
if ('/' == d)
{
if (0 == e)
{
n = n + 1;
continue;
}
else if (c / e != (float)c / (float)e)
{
n = n + 1;
continue;
}
}
if (b == '*' || b == '/')
{
if (d == '*' || d == '/')
{
if (b == '*' && d == '*')
sum = a * c * e;
else if (b == '*' && d == '/')
sum = a * c / e;
else if (b == '/' && d == '/')
sum = a / c / e;
else
sum = a / c * e;
}
else
{
if (b == '*' && d == '+')
sum = a * c + e;
else if (b == '*' && d == '-')
sum = a * c - e;
else if (b == '/' && d == '-')
sum = a / c - e;
else
sum = a / c + e;
}
}
else
{
if (d == '*' || d == '/')
{
if (b == '+' && d == '*')
sum = a +c * e;
else if (b == '+' && d == '/')
sum = a + c / e;
else if (b == '-' && d == '/')
sum = a - c / e;
else
sum = a - c * e;
}
else
{
if (b == '+' && d == '+')
sum = a + c + e;
else if (b == '+' && d == '-')
sum = a + c - e;
else if (b == '-' && d == '-')
sum = a - c - e;
else
sum = a - c + e;
}
}
Console.WriteLine("{0}{1}{2}{3}{4}={5}", a, b, c, d, e,sum);
}
Console.ReadKey();
}
}
}

运行结果;已经排除了各种意外情况

运行结果:

 

单元测试

先建立一个单元检测项目,接着就是跟着助教的演示做,但我没看到属性里的配置属性

下面图应用了我自己建的那个项目

 

 

这里面没有看到配置属性,我就没设置什么了

 

 

 单元测试这里,最开始遇到了问题,不知道怎么测试,最后在网上百度了下,测试出来了。

 

 

基本操作:下面就是基本操作截图

断点:在左边单击就行了,之后运行就行,在断点处会停止

 

性能分析:就是跟着助教的演示做的,感觉都还好

 

 

 

提交代码:

复制项目:上面已经克隆过了

 提交成功了

 

 

 

 

心得体会:

 配置过程没有什么大问题,主要的问题就是在git的运用上,第一次使用,做了很久也没学会,之后的的学习中,我会多去练习,熟悉,最后终于成功了。调试和效能分析还是比较可以的,主要就是单元测试的测试代码方面,还存在很大问题,需要去多熟悉。

posted @ 2019-03-26 16:54  赵彬zb  阅读(169)  评论(2编辑  收藏  举报