zoukankan      html  css  js  c++  java
  • 软件工程第五次作业

    题名:

    1、请运行下面code,指出其功能;

    (需附运行结果截图,并用简短文字描述其功能)

     

    功能:随机生成3个学生的姓和名以及年龄

    2、请将该code进行代码重构,使之模块化,并易于阅读和维护;

    import java.util.ArrayList;
    import java.util.List;
    import java.util.Random;
    
    
    public class Driver {
    
        private static String[] lastNames = {"Doe", "Smith", "Jones", "Adams", "Marshall", "Thompson", "Bradley", "Brown", "White", "Franklin", "Davis", "Cohn", "Clark"};
        private static String[] firstNames = {"Mary", "John", "Susan", "Michael", "David", "Lisa", "Wendy", "Diane", "Kelly", "Claire", "Elizabeth", "Mitchell", "Richard"};
    
        public static void main(String[] args) {
            
            // create an empty list
            List<Student> studentList = new ArrayList<Student>();
    
            // initialize random generator
            Random random = new Random();
            
            // create random number of students
            xunhuan(studentList, random);
            
            
        //print out the students
        for (Student temp : studentList) {
            System.out.println(temp);
            
        }
    
       }
    
        public static void xunhuan(List<Student> studentList, Random random) {
            for (int i=0; i < 3; i++) {
    
                // get random first name
                String tempFirstName = firstNames[random.nextInt(firstNames.length)];
                
                // get random last name
                String tempLastName = lastNames[random.nextInt(lastNames.length)];
                
                // get random age
                int age = 18 + random.nextInt(20);
    
                // create student
                Student tempStudent = new Student(tempLastName, tempFirstName, age);
                
                // add them to the list
                studentList.add(tempStudent);
            }
        }
    
    }

    3、观看视频The Expert (Short Comedy Sketch),写出观后感(内容是什么,说明了什么问题,有什么启示),提交到博客!

     这个视频主要讲的是一个公司要做项目开发,要求开发人员画7根红线,且7根红线必须两两垂直,而且有两个用红色墨水、有两个用绿色墨水、有一些用透明墨水来画。而且还要求用蓝墨水画红线,但是七条线两两垂直显然是不可能,但是项目经理和设计师认为开发人员就是专家,什么都会。设计师还要求开发人员把直线化成小猫的形状,这些完全不合理。

    启示:要开发一个项目要根据实际的需求去设计,而不是像那些项目经理和设计师一样的凭空去想象,认为只要是他们想得到的,专家(即开发人员)就能开发出来。

    4、学习在项目中使用 jar 文件:

    1)在下列code中导入jar文件“commons-lang3-3.3.2.jar”,并运行,将运行结果截图提交到博客:

  • 相关阅读:
    Nokia Qt SDK开发环境使用
    iPad不久将能使用Android系统
    原生IDE新军:JRuby阵营的RedCar,JavaScript阵营的Cloud9(自己写个IDE出来一定很复杂吧)
    手机产品的信息架构
    百万开发者拥戴!七大.NET著名开源项目
    Prism 4.0发布最终版,支持Windows Phone 7
    Qt Symbian 开发环境安装
    Qt 4.7.1 和 Mobility 1.1.0 已发布
    WSI闭关,这对WS*意味着什么?(个人觉得Web Services是个好东西)
    ERROR: unknown virtual device name解决方法
  • 原文地址:https://www.cnblogs.com/lizhuanyan/p/4513623.html
Copyright © 2011-2022 走看看