顾小排的第二次作业

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

介绍 答案
GIT地址 https://github.com/gy722
GIT用户名 gy722
学号后五位 24212
博客地址 https://home.cnblogs.com/u/gy722/
作业链接 https://edu.cnblogs.com/campus/xnsy/GeographicInformationScience/homework/7582

1、配置环境

安装配置 Visual Studio。上学期的C#课安装的VS2010,因为下载安装的错误,我直接重新下载了2019版。

2、设计思路

程序的代码如下:

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

生成四则运算式

namespace  顾毓的第二次作业
    {
        public class Program
        {
            //生成四则运算式
            public static char[] op = { '+', '-', '*', '/' };
            public static string Exam()
            {
                Random num = new Random();
                int num1, num2, operators, opnum, i;
                num1 = num.Next(0, 101);
                operators = num.Next(2, 4);
                string equation = null;
                equation += num1;
                for (i = 0; i < operators; i++)
                {
                    num2 = num.Next(0, 101);
                    opnum = num.Next(0, 4);
                    equation = equation + op[opnum] + num2;
                }
                return equation;
            }

生成答案

//生成答案
public static string operation(string equation)
{

object o = new DataTable().Compute(equation, "");
while (o.ToString().Contains("."))
{
equation = Exam();
o = new DataTable().Compute(equation, "");
}
string result = equation + "=" + o.ToString();
return result;
}
public static void Main(string[] args)
{

int n;
string result = null;
Console.WriteLine("请输入题目数量:");
n = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < n; i++)
{
result = result + operation(Exam()) + "\n";
}
Console.WriteLine(result);
FileStream fs = new FileStream(@"D:\subject.txt", FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
sw.Write("operation");
sw.Close();
fs.Close();

}

}
}

![图为运行结果]( https://img-blog.csdnimg.cn/20190920115442357.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2d5NzIy,size_16,color_FFFFFF,t_70)

3、克隆git代码

1.登陆好已经注册好的账号
![图片为注册安装Git]( https://img-blog.csdnimg.cn/20190920114413531.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2d5NzIy,size_16,color_FFFFFF,t_70)2.处理克隆的基础操作
![将阿超的四则运算库拷贝到自己的同名仓库中]( https://img-blog.csdnimg.cn/20190920114526597.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2d5NzIy,size_16,color_FFFFFF,t_70)

3、单元测试

创建新项目,选择单元测试项目
![配置新项目]( https://img-blog.csdnimg.cn/20190920121853261.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2d5NzIy,size_16,color_FFFFFF,t_70)引进待测试项目
![引入测试项目]( https://img-blog.csdnimg.cn/2019092012225018.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2d5NzIy,size_16,color_FFFFFF,t_70)

测试

很多错误点都不清楚原因,也不知道从哪里改,怎么改,2019版使用很不熟练。
![未成功测试]( https://img-blog.csdnimg.cn/20190920150634353.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2d5NzIy,size_16,color_FFFFFF,t_70)

提交代码

![创建git push]( https://img-blog.csdnimg.cn/20190920142915644.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2d5NzIy,size_16,color_FFFFFF,t_70)
![链接仓库 ]( https://img-blog.csdnimg.cn/20190920143503955.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2d5NzIy,size_16,color_FFFFFF,t_70)
![提交到github]( https://img-blog.csdnimg.cn/20190920144241990.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2d5NzIy,size_16,color_FFFFFF,t_70)

总结

这次作业的难度很大,我们不仅对软件零了解,还对实际的操作不懂,同时代码上也还存在很多不会的地方。我会抓紧时间复习之前的知识,在作业中,多去学习了解做什么,怎么做?提高自己动手的能力。

posted @ 2019-09-20 15:29  顾小排  阅读(176)  评论(2)    收藏  举报