第二次作业

第二次作业:熟悉工具使用

Github地址 https://github.com/BinyuanLei
Github用户名 BinyuanLei
学号后五位 24116
博客地址 https://home.cnblogs.com/u/leibinyuan
作业链接 https://edu.cnblogs.com/campus/xnsy/GeographicInformationScience/homework/7582

一、配置环境

1.VS2017的安装。
这里是安装成功的截图。
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190919100124480.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)
2.Github的安装与配置。
这里是安装成功后使用GIT Bash的截图。
![安装完成后的截图]( https://img-blog.csdnimg.cn/20190919100246496.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)

二、克隆项目

1.创建自己的Github账号。
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190919190717909.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)
2.登录自己的Github网址。
3.进入阿超仓库,点击右上角的Fork,拷贝到自己的同名仓库。

![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190920170500682.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)
4.将项目克隆到电脑文件夹
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190920170427461.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)

三、设计随机数四则运算

1.新建控制台
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190919191606920.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)
2.书写代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace App
{
public class Problem
{
public int a, b, c, d,n , sum;
char[] s = { '+', '-', '', '/' };
public Problem(int n) { }
public void Print()
{
Random random = new Random();
Console.WriteLine("请输入四则运算题目个数:");
n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
// char s1 = s[t];
int t = random.Next(1, 9);
//char s2 = s[t];
a = random.Next(1, 100); //生成1-100之间的随机数
b = random.Next(1, 100);
c = random.Next(1, 100);
d = random.Next(1, 100);
if (t == 1)
{
sum = a + b + c;
Console.WriteLine(a + "+" + b + "+" + c + "=" + sum);
}
else if (t == 2)
{
c = random.Next(1, a + b);
for (; a + b - c < 0;)
c = random.Next(1, a + b);
sum = a + b - c;
Console.WriteLine(a + "+" + b + "-" + c + "=" + sum);
}
else if (t == 3)
{
sum = a + b * c;
Console.WriteLine(a + "+" + b + "
" + c + "=" + sum);
}
else if (t == 4)
{
for (; b % c != 0; c = random.Next(1, b))
c = random.Next(2, b);
sum = a + b / c;
Console.WriteLine(a + "+" + b + "/" + c + "=" + sum);
}
else if (t == 5)
{
for (; b % c != 0;)
c = random.Next(2, b);
sum = a * d + b / c;
Console.WriteLine(a + "" + d + "+" + b + "/" + c + "=" + sum);
}
else if (t == 6)
{
for (; b % c != 0; c = random.Next(1, b))
d = random.Next(2, a);
sum = a + b / c - d;
Console.WriteLine(a + "+" + b + "/" + c + "-" + d + "=" + sum);
}
else if (t == 7)
{
for (; b % c != 0;)
c = random.Next(1, b);
sum = a + b / c * d;
Console.WriteLine(a + "+" + b + "/" + c + "
" + d + "=" + sum);
}
else if (t == 8)
{
sum = a * b + c * d;
Console.WriteLine(a + "" + b + "+" + c + "" + d + "=" + sum);
}
else if (t == 9)
{
for (; c % d != 0;)
d = random.Next(1, c);
sum = a * b + c / d;
Console.WriteLine(a + "*" + b + "+" + c + "/" + d + "=" + sum);
}
}
}
public void Writew()
{
string fileName = @"C: \Users\ASUS\Desktop\AchaoCalculator\BinyuanLei";
StreamWriter sa = new StreamWriter(fileName);
sa.WriteLine();
sa.Flush();
}
}
class Program
{
static void Main(string[] args)
{
Problem v = new Problem(1);
v.Print();
Console.Read();
}
}
}

运算结果:
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190919112337981.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)

四、单元测试

1.新建一个测试项目。
![在这里插入图片描述]( https://img-blog.csdnimg.cn/2019091919282654.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)
2.在项目创建成功后,为单元测试项目 APP 增加对原项目的引用,以实现调用原项目函数接口的功能。
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190919193517902.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)
3.开始写单元测试代码
步骤①:创建单元测试,添加引用
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190920143704294.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)
步骤②:添加引用
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190920143914541.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)
步骤三:测试运行

![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190920150027835.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)

五、回归测试

单元测试不仅仅用来保证当前代码的正确性,更重要的是用来保证代码修复、改进或重构之后的正确性。也就是说,在每次修改完 Bug 之后,我们其实都需要运行一遍来看看是不是满足之前所有的单元测试样例。

六、效能工具

1.点击性能探测器
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190920151303430.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)
2.选择CUP选项
![在这里插入图片描述]( https://img-blog.csdnimg.cn/2019092015141349.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)
3.分析结果
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190920152222266.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)

七、提交代码

![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190920174617950.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)
提交成功后
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20190920174647323.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NDQ4NDE5,size_16,color_FFFFFF,t_70)

八、个人感受

本次作业太让人头痛了,关于软件安装问题,下载了2次后,才有了可以用来完成作业的组件。
对于代码的编写,由于忘记大半,在网上搜索了代码后经过几次更改最后能完成实验,但还存在瑕疵,并不知道如何改正。
我按照步骤一步步做,但是有些步骤始终理解不了。整个人都几近疯狂。
但是收获也是挺多的,熟悉了一些工具的使用,回顾了代码的书写规则,锻炼了自己的耐心。

posted on 2019-09-20 17:39  雷槟源  阅读(158)  评论(0)    收藏  举报

导航