第二次作业
GIT地址 | 连接 |
GIT用户名 | yszmxtl |
学号后五位 | 62233 |
博客地址 | 连接 |
作业链接 | https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass1/homework/2793 |
1.环境配置过程
我是用的网盘下的,因为当初装过很多次,所以这次比较容易,没什么问题,就说说以前的问题吧,就是安装路径不知道怎么改,因为这个软件内存大,因此,前面几次几乎都是装的c盘,这次也是改了路径,但依然有插件装在c盘,内存有剩了不多了,去网上百度说这是必须的,要不然有的软件没法运行就没管了。
2.代码设计
代码构思:我是想先用一个函数生成随机数,判断几位数进行计算,然后再传值给另外两个函数分别获得符号和数字,然后再用一个函数专门判断是否为小数,获得的数用list进行存储,然而后面发现行不通,不能计算,于是将两个函数去掉,换成两个分别计算2位和3位的函数,我一直觉得原来那种构思应该比较方便,然而后面算不出来,因此换成了这种,另外还有时间的关系,代码截图见下(好像截图不能太大,直接上传):
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections.Generic; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int varible_1, varible_2;//定义变量 Rand rand1 = new Rand(); Console.WriteLine("请输入你需要多少道题:"); varible_1 = Convert.ToInt32(Console.ReadLine()); for (varible_2 = 0; varible_2 < varible_1; varible_2++) { rand1.digit(); } } } class Rand //获取随机 { public static float value; public void digit()//获取这个算式中有多少位数 { int varible_1, varible_2; Random random = new Random(Guid.NewGuid().GetHashCode()); varible_1 = random.Next(2, 4); if (varible_1 == 2) count_2(); else count_3(); } public void count_2()//两位数计算 { for(int a=0;;a++) { int varible_1, varible_2; float varible_11, varible_21, value; string symbol;//记录符号 Random random = new Random(Guid.NewGuid().GetHashCode()); varible_1 = random.Next(100); varible_2 = random.Next(100); varible_11 = varible_1; varible_21 = varible_2;//将得到的两个值赋值 varible_1 = random.Next(4); if (varible_1 == 0) { value = varible_11 + varible_21; symbol = "+"; if (jugement(value) == 1) { Console.WriteLine(varible_11 +symbol + varible_21+"="+value); break; } else continue; } else if (varible_1 == 1) { symbol = "-"; value = varible_11 - varible_21; if (jugement(value) == 1) { Console.WriteLine(varible_11 +symbol + varible_21 + "=" + value); break; } else continue; } else if (varible_1 == 2) { symbol = "*"; value = varible_11 * varible_21; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol + varible_21 + "=" + value); break; } else continue; } else if (varible_1 == 3) { symbol = "/"; value = varible_11 / varible_21; if (jugement(value) == 1) { Console.WriteLine(varible_11 +symbol + varible_21 + "=" + value); break; } else continue; } } } public void count_3() { for (int a = 0; ; a++) { int varible_1, varible_2,varible_3; float varible_11, varible_21,varible_31, value; string symbol1, symbol2;//记录符号 Random random = new Random(Guid.NewGuid().GetHashCode()); varible_1 = random.Next(100); varible_2 = random.Next(100); varible_3 = random.Next(100); varible_11 = varible_1; varible_21 = varible_2; varible_31 = varible_3;//将得到的三个值赋值 varible_1 = random.Next(4); if (varible_1 == 0) { symbol1 = "+"; value = varible_11 + varible_21; if (jugement(value) == 1) { Random random1 = new Random(Guid.NewGuid().GetHashCode()); varible_1 = random1.Next(4); if(varible_1==0) { symbol2 = "+"; value = value + varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if(varible_1==1) { symbol2 = "-"; value = value - varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if(varible_1==2) { symbol2 = "*"; value = value * varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if(varible_1==3) { symbol2 = "/"; value = value / varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } } else continue; } else if (varible_1 == 1) { symbol1 = "-"; value = varible_11 - varible_21; if(jugement(value)==1) { varible_1 = random.Next(4); if (varible_1 == 0) { symbol2 = "+"; value = value + varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if (varible_1 == 1) { symbol2 = "-"; value = value - varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if (varible_1 == 2) { symbol2 = "*"; value = value * varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if (varible_1 == 3) { symbol2 = "/"; value = value / varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } } else continue; } else if (varible_1 == 2) { symbol1 = "*"; value = varible_11 * varible_21; if (jugement(value) == 1) { varible_1 = random.Next(4); if (varible_1 == 0) { symbol2 = "+"; value = value + varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if (varible_1 == 1) { symbol2 = "-"; value = value - varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if (varible_1 == 2) { symbol2 = "*"; value = value * varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if (varible_1 == 3) { symbol2 = "/"; value = value / varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } } else continue; } else if (varible_1 == 3) { symbol1 = "/"; value = varible_11 / varible_21; if (jugement(value) == 1) { varible_1 = random.Next(4); if (varible_1 == 0) { symbol2 = "+"; value = value + varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if (varible_1 == 1) { symbol2 = "-"; value = value - varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if (varible_1 == 2) { symbol2 = "*"; value = value * varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } else if (varible_1 == 3) { symbol2 = "/"; value = value / varible_31; if (jugement(value) == 1) { Console.WriteLine(varible_11 + symbol1 + varible_21 + symbol2 + varible_31 + "=" + value); break; } else continue; } } else continue; } } } public int jugement(float n)//判断是否为小数 { if (n % 1.0 == 0) return 1; else return 0; } } }
3.github克隆项目以及提交代码
克隆项目简单,直接按照网上来的就行,下面的截图是我参照群里的文件模仿的一部分截图
4.单元测试和回归测试
这部分不会。
5.感想
尝试一个新东西太困难了,发现之前的c#代码也有很多不会,还要去查资料,另外这个git和测试之类的不会,这次是我自己时间拖太久了,现在发现赶不上,但我觉得我的代码还行,能勉强过去,其他的步骤软件是不怎么经操作过,希望最后能不能有这次试验的步骤之类的,网上和群里的git步骤真的对不上,群里那个master根本没看到,网页上的更别说了,单元测试网上点开测试后,只有一个属性,而我这有4个,都点进去哪一个和后面的步骤都合不上,更别说写测试之类的,因此深切渴求这次的步骤。