20181127-1附加作业 软件工程原则的应用实例

此作业的要求参见:【https://edu.cnblogs.com/campus/nenu/2018fall/homework/2446】

在软件工程中存在很多原则,在我的代码作业和非代码作业中均有体现。

一.首先分析我的代码作业:

在我的代码作业中,满足了一些原则。代码要满足用户的需求,满足用户的需求是我们书写出正确代码的前提。在完成用户需求是,我也犯了很多错误,没有按照输入的要求进行输入,虽然得到了正确的结果,但这也算不符合用户需求;在进行结对编程时,要提前制定代码编写的代码规范,然后在进行代码的编写;在代码书写之后,要进行再次测试,以保证代码的精准性。

代码的连接如下:

词频统计的代码地址:https://git.coding.net/sunsss/work.git

代码如下:

import reclass WF():def __init__(self):self.file_name = input('please input the name of book:')self.mappings = {}self.get_words()self.console_print()self.__init__()def get_words(self):file_tail = '' if '.txt' in self.file_name else '.txt'with open (self.file_name + file_tail, 'r', encoding = 'utf-8') as f:for line in f:for i in re.sub(r'[^\w\s]','', line).replace('\n','').split(' '):if i not in self.mappings:self.mappings[i] = 1else:self.mappings[i] += 1def console_print(self):for k, w in self.mappings.items():print(k, w)print('\ntotal: %swords' % len(self.mappings))WF()

该代码没有完成功能三和功能四,在之后的效能测试中,也没有办法完成。

四则运算的代码地址:https://git.coding.net/sunsss/two.git

代码如下:

(1)功能1

 1 import random
 2 ops = ['+','-','*','/']
 3 com = input('>') #用户输入
 4 cot = 0 #答对的题
 5 x = 0
 6 while x < 20 :
 7     s1 = random.randint(1,10)
 8     s2 = random.randint(1,10)
 9     s3 = random.randint(1,10)
10     s4 = random.randint(1,10)
11     op1 = random.choice(ops) #随机运算符
12     op2 = random.choice(ops)
13     op3 = random.choice(ops)
14     while op1 == op2 == op3:
15         op1 = random.choice(ops) #随机运算符
16         op2 = random.choice(ops)
17         op3 = random.choice(ops)
18     eq = (str(s1)+op1+str(s2)+op2+str(s3)+op3+str(s4))
19     res = eval(eq)
20     if len(str(res) ) > 5:
21         continue
22     x += 1
23     print(eq)
24     in_res =eval( input('?'))
25     if in_res == res:
26         print('算对啦,你真是个天才!')
27         cot += 1
28     else:
29         print('再想想吧,答案似乎是%s喔!'%res)
30
31 print('你一共答对%s道题,共20道题'%cot)

(2)功能2

 1 from random import randint
 2 from random import choice
 3 ops = ['+','-','*','/']
 4 bra = ['(', '', ')']
 5 com = input('>') #用户输入
 6 cot = 0 #答对的题
 7 x = 0
 8 while x < 20 :
 9     s1 = randint(1,10)
10     s2 = randint(1,10)
11     s3 = randint(1,10)
12     s4 = randint(1,10)
13     op1 = choice(ops) #随机运算符
14     op2 = choice(ops)
15     op3 = choice(ops)
16     """括号"""
17     bra_1 = ['' , '' ,'']
18     bra_2 = ['' , '' , '']
19     i = ii =0
20     while (i ==0 and ii ==2) or abs(i-ii)==1 \
21         or ii < i  :
22         i = randint(0,2)
23         ii = randint(0,2)
24
25     bra_1[i] = '(';   bra_2[ii]=')'
26
27     while op1 == op2 == op3 :
28         op1 = choice(ops) #随机运算符
29         op2 = choice(ops)
30         op3 = choice(ops)
31
32     eq = bra_1[0] + str(s1) + op1 + bra_1[1] + str(s2) + \
33     bra_2[0] + op2 + bra_1[2] + str(s3) + bra_2[1] + op3 \
34     + str(s4) + bra_2[2]
35     res = eval(eq)
36     if len(str(res) ) > 5:
37         continue
38     x += 1
39     print(eq)
40     in_res =eval( input('?'))
41     if in_res == res:
42         print('算对啦,你真是个天才!')
43         cot += 1
44     else:
45         print('再想想吧,答案似乎是%s喔!'%res)
46
47 print('你一共答对%s道题,共20道题'%cot)

(3)功能3

 1 from random import randint
 2 from random import choice
 3 import os
 4 ops = ['+','-','*','/']
 5 bra = ['(', '', ')']
 6 com = input('>') #用户输入
 7 com_list = com.split()
 8 while com_list[2].isdigit() == False:
 9     print('题目数量必须是正整数')
10     com = input('>') #用户输入
11     com_list = com.split()
12
13 def xx():
14     s1 = randint(1,10)
15     s2 = randint(1,10)
16     s3 = randint(1,10)
17     s4 = randint(1,10)
18     op1 = choice(ops) #随机运算符
19     op2 = choice(ops)
20     op3 = choice(ops)
21     """括号"""
22     bra_1 = ['' , '' ,'']
23     bra_2 = ['' , '' , '']
24     i = ii =0
25     while (i ==0 and ii ==2) or abs(i-ii)==1 \
26         or ii < i  :
27         i = randint(0,2)
28         ii = randint(0,2)
29
30     bra_1[i] = '(';   bra_2[ii]=')'
31
32     while op1 == op2 == op3 :
33         op1 = choice(ops) #随机运算符
34         op2 = choice(ops)
35         op3 = choice(ops)
36
37     eq = bra_1[0] + str(s1) + op1 + bra_1[1] + str(s2) + \
38     bra_2[0] + op2 + bra_1[2] + str(s3) + bra_2[1] + op3 \
39     + str(s4) + bra_2[2]
40     res = eval(eq)
41     return [eq,res]
42
43
44
45 eq = [];  res = []
46 while len(res) < int(com_list[2]):
47     a = xx()
48     if a[1] in res or len((str(a[1])) ) >6: #结果一样的直接就不要
49         continue
50     eq.append(a[0])
51     res.append(a[1])
52
53 f= open('题目.txt','w')
54 for i in range(len(eq)):
55     print('{0:15}'.format(eq[i]),end = '')
56     print(res[i])
57     xxx = 17 - len(eq[i])
58     f.write(str(eq[i]+' '*xxx))
59     f.write(str(res[i])+'\n')
60 f.close()
61 os.system('题目.txt')  #决定是否打开txt

(4)功能4

 1 import os
 2 from random import randint
 3 from random import choice
 4 from fractions import Fraction
 5 ops = ['+','-','*','/']
 6 bra = ['(', '', ')']
 7 com = input('>') #用户输入
 8 com_list = com.split()
 9 while com_list[2].isdigit() == False:
10     print('题目数量必须是正整数')
11     com = input('>') #用户输入
12     com_list = com.split()
13
14 def xx():
15     s1 = randint(1,10)
16     s2 = randint(1,10)
17     s3 = randint(1,10)
18     s4 = randint(1,10)
19     op1 = choice(ops) #随机运算符
20     op2 = choice(ops)
21     op3 = choice(ops)
22     """括号"""
23     bra_1 = ['' , '' ,'']
24     bra_2 = ['' , '' , '']
25     i = ii =0
26     while (i ==0 and ii ==2) or abs(i-ii)==1 \
27         or ii < i  :
28         i = randint(0,2)
29         ii = randint(0,2)
30
31     bra_1[i] = '(';   bra_2[ii]=')'
32
33     while op1 == op2 == op3 :
34         op1 = choice(ops) #随机运算符
35         op2 = choice(ops)
36         op3 = choice(ops)
37
38     eq = bra_1[0] + str(s1) + op1 + bra_1[1] + str(s2) + \
39     bra_2[0] + op2 + bra_1[2] + str(s3) + bra_2[1] + op3 \
40     + str(s4) + bra_2[2]
41     res = Fraction(eval(eq))
42     return [eq,res]

在这次代码书写中,我和我的同学结对完成,我们提出彼此的想法,提出不同的意见,这次编程是我们两个人都得到了进步。我们在满足客户需求的同时,还根据我们的想法对代码进行了优化。

二.其次分析我的非代码作业

第一周的博文作业,算是接触软件工程的第一课,存在着这样一项原则,在回答你的优点是什么,你是如何达到今天的进步的问题?我们回答问题时,要给出具体努力的过程,要有能进行衡量标准你的努力。这个原则让我颇为受用;每周例行报告的书写,进行一切实时记录,使我联想到了git版本控制,这样做的目的是是是存储代码,防止出现意外代码消失;吉林市两日游,对事先会发生的情况未雨绸缪,提出两套及以上的方案来应对。

转载于:https://www.cnblogs.com/swn321/p/10048659.html

20181127-1附加作业 软件工程原则的应用实例相关推荐

  1. 作业要求 20181127-1 附加作业 软件工程原则的应用实例分析

    本次作业要求参加:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2446 在本学期我们首先略读了<构建之法>这本书,通过这本书 ...

  2. 20181127-1 附加作业 软件工程原则的应用实例分析

    此作业要求参见:[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2446] 1.从开学到今天的所有每周例行报告写用到的软件工程知识点一栏都 ...

  3. 【附加作业】沈航软件工程期末附加作业

    附加作业回答以下几个问题: 你认为本门课程需要在哪里进行改进,具体措施有哪些,包括:时间进度安排,项目难度等均可:                                           ...

  4. 个人作业——软件工程实践总结

    一.请回望暑假时的第一次作业,你对于软件工程课程的想象 对比开篇博客你对课程目标和期待,"希望通过实践锻炼,增强计算机专业的能力和就业竞争力",对比目前的所学所练所得,在哪些方面达 ...

  5. 【评分】个人作业——软件工程实践总结作业

    [评分]个人作业--软件工程实践总结作业 总结 按时交 - 有分 晚交 - 0分 迟交一周以上 - 倒扣本次作业分数 抄袭 - 倒扣本次作业分数 本次作业 蔡安琪 同学相较更认真仔细,大家可前往参考: ...

  6. 福大软工 · 最终作业 - 软件工程实践总结(个人)

    一.请回望暑假时的第一次作业,你对于软件工程课程的想象 1)对比开篇博客你对课程目标和期待,"希望通过实践锻炼,增强计算机专业的能力和就业竞争力",对比目前的所学所练所得,在哪些方 ...

  7. C语言作业(软件工程),C语言作业(软件工程)

    1.习题一 C 语言基础知识1. 写出一个 C 程序的构成2. 编写一个 C 语言程序,输出以下信息:* * * * * * * * * *How are you!* * * * * * * * * ...

  8. html网页设计期末大作业——酒庄网页设计实例(5页)

    html网页设计期末大作业--酒庄网页设计实例(5页) 常见网页设计作业题材有 个人. 美食. 公司. 学校. 旅游. 电商. 宠物. 电器. 茶叶. 家居. 酒店. 舞蹈. 动漫. 明星. 服装. ...

  9. 附加作业:个人作业——案例分析

    Deadline: 2018-12-24 10:00PM,以提交至班级博客时间为准. 如果你觉得你的总评成绩不理想或者希望再提高,请根据博客要求,写一篇个人随笔 参考来自: http://www.cn ...

最新文章

  1. Keil : Cannot enter Debug Mode解决方法:
  2. Codeforces 766E Mahmoud and a xor trip(树形DP)
  3. python selenium po模式_Python+Selenium+Unittest实现PO模式web自动化框架
  4. 路飞学院python官网-路飞学院-Python爬虫实战密训班-第1章
  5. STL——vector容器详解
  6. Mybaits之Mapper动态代理开发
  7. 软件项目文档_什么是软件项目的好的文档?
  8. blob数据类型_MySQL 8.0 基本操作步骤:3.字段和数据类型的选择
  9. unix到底有啥用_微信新上线的「拍拍」到底有啥用?
  10. 【语音识别】基于matlab说话人识别系统【含Matlab源码 1704期】
  11. 惠普HP Deskjet D1530 打印机驱动
  12. kindeditor php 漏洞,KindEditor漏洞、优化以及漏洞、BUG修复方案汇总
  13. IE浏览器打开网页之后,右键,选择“查看源文件”后打开桌面窗口的问题
  14. 红色印章制作过程记录
  15. 那些年我们一起手写过的单例
  16. MySql delete多表关联删除的使用方法
  17. 第二章 基本Bean的装载
  18. 如何开启 vue 项目
  19. 中国探月计算机考试时间,中国探月工程三级跳:嫦娥一号到嫦娥三号
  20. 比才干更重要的,是底层逻辑

热门文章

  1. Linux上机实验1
  2. Vista及Win7常见故障(拷贝)
  3. linux安装 java jdk
  4. java的注释规范_Java代码注释规范
  5. 设置cookie存活时间_Django之cookie、session、token
  6. Linux 设置端口转发
  7. Zookeeper Api(java)入门与应用
  8. 两个排序数组的中位数(4.Median of Two Sorted Arrays)
  9. U811.1接口EAI系列之一--通用把XML传送给EAI处理方法--PowerBuilder语言
  10. ubuntu 18.04 LTS 国内源安装docker