zoukankan      html  css  js  c++  java
  • 《个人软件开发流程》——申同燕

    1.需求分析:

    根据用户输入的题目个数,产生含有2个数字,1种运算符的题目,并显示出来。

    2.核心代码:

    复制代码
    package entity;
    
    import java.util.ArrayList;
    import java.util.Random;
    import java.util.Scanner;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Random;
    import java.util.function.BiFunction;
    
    /**
     * 试卷实体类
     */
    public class Exam {
    
        private List<Subject> subjectList;
    
        public List<Subject> getSubjectList() {
            return subjectList;
        }
    
        public void setSubjectList(List<Subject> subjectList) {
            this.subjectList = subjectList;
        }
    
        public Exam() {
            System.out.println("请输入要生成几道题目:");
            Scanner sc = new Scanner(System.in);
            int count = sc.nextInt();
            List<Subject> list = new ArrayList<Subject>();
            BiFunction<Integer, Integer, Integer> add = (x, y) -> x + y;
            BiFunction<Integer, Integer, Integer> minus = (x, y) -> x - y;
            BiFunction<Integer, Integer, Integer> multiple = (x, y) -> x * y;
            BiFunction<Integer, Integer, Integer> divide = (x, y) -> x / y;
            for (int i = 0; i < count; i++) {
                Subject subject = new Subject();
                Integer a = new Random().nextInt(99);
                Integer b = new Random().nextInt(99);
                subject.setA(a);
                subject.setB(b);
                subject.setIndex(i + 1);
                Integer symbol = new Random().nextInt(3);
                if (symbol == 0) {
                    subject.setSymbol("+");
                    subject.setAnswer(add.apply(a, b));
                } else if (symbol == 1) {
                    subject.setSymbol("-");
                    subject.setAnswer(minus.apply(a, b));
                } else if (symbol == 2) {
                    subject.setSymbol("×");
                    subject.setAnswer(multiple.apply(a, b));
                } else if (symbol == 3) {
                    subject.setSymbol("÷");
                    subject.setAnswer(divide.apply(a, b));
                }
                list.add(subject);
            }
            this.subjectList = list;
    
        }
    
        public static void main(String[] args) {
            Exam exam = new Exam();// 随机出题
            
            // 查看试卷
            exam.getSubjectList().forEach(subject -> {
                System.out.println("第" + subject.getIndex() + "题:" + subject.getA() + " " + subject.getSymbol() + " "
                        + subject.getB() +"=");
            });
            System.out.println("输出你的答案,每题答案之间用空格分开:");
            System.out.println();
            Scanner sc = new Scanner(System.in);
            int count = sc.nextInt();
            System.out.println("-----------*答案为*----------");
            exam.getSubjectList().forEach(subject -> {
                System.out.println("第" + subject.getIndex() + "题答案:"+ subject.getAnswer());
            });
        }
    
    }
    
    /**
     * 定义题目的类
     *
     */
    class Subject {
    
        private Integer index;
    
        private Integer a;
    
        private Integer b;
    
        private String symbol;
    
        private Integer answer;
    
        public Integer getIndex() {
            return index;
        }
    
        public void setIndex(Integer index) {
            this.index = index;
        }
    
        public Integer getA() {
            return a;
        }
    
        public void setA(Integer a) {
            this.a = a;
        }
    
        public Integer getB() {
            return b;
        }
    
        public void setB(Integer b) {
            this.b = b;
        }
    
        public String getSymbol() {
            return symbol;
        }
    
        public void setSymbol(String symbol) {
            this.symbol = symbol;
        }
    
        public Integer getAnswer() {
            return answer;
        }
    
        public void setAnswer(Integer answer) {
            this.answer = answer;
        }
    
    }
    复制代码

    3.PSP对照表

    PSP

    任务内容

    计划共完成需要的时间(min)

    实际完成需要的时间(min)

    Planning

    计划

    25

    30

       Estimate

     · 估计这个任务需要多少时间,并规划大致工作步骤

    25

    30

    Development

    开发

    248

    323

       ·Analysis

    ·分析需求

    15

    20

       ·Design Spec

    ·生成设计文档

    20

    25

       ·Design Review

    ·设计复审

    8

    10

       ·Coding Standard

    ·代码规范

    5

    3

       ·Design

    ·具体设计

    25

    30

       ·Coding

    ·具体编码

    120

    160

       ·Code Review

    ·代码复审

    30

    45

       ·Test

    ·测试

    25

    30

    Record Time Spent

    记录用时

    27

    31

    Test Report

    测试报告

    15

    17

    Size Measurement

    计算工作量

    7

    8

    Postmorterm

    事后总结

    5

    6

    4.总结

       具体编码与代码复审较为费时间,许多方法都忘记了,具体编码环节估计和实践差距太大了。总体来说,磕磕绊绊写完了。还是要多加练习。

  • 相关阅读:
    mybatis由浅入深day01_6SqlMapConfig.xml(6.2settings全局参数配置_6.3typeAliases(类型别名)_6.4typeHandlers(类型处理器)_6.5mappers(映射配置))
    mybatis由浅入深day01_5.3 Mapper动态代理方法
    mybatis由浅入深day01_5mybatis开发dao的方法(5.1SqlSession使用范围_5.2原始dao开发方法)
    mybatis由浅入深day01_ 4.11总结(parameterType_resultType_#{}和${}_selectOne和selectList_mybatis和hibernate本质区别和应用场景)
    mybatis由浅入深day01_4.9删除用户_4.10更新用户
    mybatis由浅入深day01_4.7根据用户名称模糊查询用户信息_4.8添加用户((非)自增主键返回)
    mybatis由浅入深day01_4入门程序_4.6根据用户id(主键)查询用户信息
    mybatis由浅入深day01_3mybatis框架介绍
    mybatis由浅入深day01_1课程安排_2对原生态jdbc程序中问题总结
    工作流JBPM_day02:3-预定义的活动1_4-预定义的活动2+在图片上高亮显示正在执行的上活动
  • 原文地址:https://www.cnblogs.com/shuliqiu0320/p/14643237.html
Copyright © 2011-2022 走看看