标签:
题名:
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”,并运行,将运行结果截图提交到博客:
标签:
原文地址:http://www.cnblogs.com/forever1999/p/4542624.html