讲解:JavaArrayList Homework Java、Java

Introduction成果编写使用对象的程序编写使用ArrayList的程序编写使用抽象类和接口的程序使用面向对象编程概念编写应用程序在包中组织类评分如果你没有提交包含源代码的.zip文件,你的分数将为零。如果你提交的源代码不能编译,你的分数将为零。如果您提交的源代码没有正确的类名或正确的方法名称(见下文),你的分数将减少50分。此外,不满足以下要求将被扣分:在每个java文件的开头,添加一条注释,其中包含以下信息:学生姓名课程/部分日期文件名程序/类的描述缩进指南:类内部的代码必须相对于类定义缩进。方法内部的代码必须相对于方法定义缩进。if / else / else if / while / for / do-while结构中的代码必须相对于其相应的结构缩进。大括号可以放置在相应结构的末端花括号可以放置在相应的结构定义的末尾,或者放置在与相应结构对齐的以下行中。注释:至少应该为每个方法或构造函数添加单行注释。注释必须描述该方法的功能或目标。如果你认为这将有助于分级,请添加更多关于你的代码的注释。专栏描述这项任务包括三种解决方案的开发。 每个解决方案都应该存储在自己的文件夹中。 将名为Homework04.zip的zip文件中的解决方案文件夹提交到Canvas中的相应分配。PersonSolution1.创建一个名为PersonSolution的项目。2.使用教科书练习P9.8中提供的描述,生成三个类及其相应的方法。实现一个超类Person,创建两个类Student和Instructor,继承Person。Person对象有name和birth,Student对象有major,指导老师有salary,为所有类写入类声明,构造函数和toString方法,提供测试这些类和方法的测试程序。3.这些类应该打包到school包内4.将person类定义为抽象类5.编写一个程序只测试Instructor和Student类。测试程序的名称应该是PersonTest。6.在此程序中,为Instructor和Student类创建单独的对象。为每个对象提供必要的信息。 然后,分别测试每个类并使用toString方法显示其输出。DistanceSolution1.创建一个名为DistanceSolution的项目2.创建一个Distance类3.类放到metrics包中4.Distance类中创建两个名为manhattanDistance和euclideanDistance的静态方法5. manhattanDistance方法接收两个Double数组列表作为参数。a.如果这两个列表不包含相同数量的元素,则此方法返回-1b.否则,该方法应该计算两个向量之间的曼哈顿距离并将其作为double值返回。c.有关如何计算两个向量之间曼哈顿距离的更多信息,请参阅6.euclideanDistance方法接收两个Double数组列表作为参数a. 如果数组列表不包含相同数量的元素,则此方法返回-1b.否则,该方法应该计算两个向量之间的欧几里德距离并将其作为双精度值返回。7.创建一个测试这些方法的程序。将此程序命名为DistanceTest。8.在DistanceTest中a.创建两个大小为3的数值数组列表。为这些数组列表提供double值。b.显示这些数组列表的内容。c.通过调用manhattanDistance方法显示这些向量之间的曼哈顿距离(数组列表)。d.创建大小为5的其他两个数值数组列表。为这些数组列表提供double值。e.显示这些数组列表的内容。f.通过调用euclideanDistance方法显示这些向量(数组列表)之间的欧几里德距离。RectangleSolution1.创建名为RectangleSolution的项目2. 类java.awt.Rectangle不包含计算Rectangle对象面积的方法; 它也没有实现接口Comparable。3.创建一个名为ComparableRectangle的Rectangle类的子类,它也实现了Comparable接口。4.将该类包含在名为geometry的包中。5. 创建一个接收两个参数width和height的构造函数。使用这些参数来初始化ComparableRectangle对象中的相应实例变量。6.创建一个名为getArea的公共方法,该方法返回ComparableRectangle对象的面积。7.实现方法compareTo。请记住,此方法接收另一个ComparableRectangle作为参数。8.创建一个测试这个类的程序。将该程序命名为RectangleTest。9.在RectangleTest中:a.创建三个ComparableRectangle对象,第一个和第二个ComparableRectangle对象有相同的宽度和高度,第三个ComparableRectangle对象有不同的宽度和高度b. 通过使用toString方法显示这些ComparableRectangle对象的度量值c. 另外,显示通过比较获得的结果:第一个与第二个ComparableRectangle对象比较第一个和第三个ComparableRectangle对象比较第三个和第二个ComparableRectangle对象比较RequirementCSE 271, Object-Oriented Programming, Spring 2018Homework 04, 100 pointsDue Saturday, March 3, 2018 by 11:59 pmHomework 04Outcomes§ Write programs that use objects.§ Write programs that use ArrayList.§ Write programs that use abstract classes, and interfaces.§ Write applications using object oriented programming concepts.§ Organize classes in packages.Scoring§ If you do not submit a .zip file containing your source code, your score will be zero.§ If you submit source code that does not compile, your score will be zero.§ If you submit source code without the correct class name(s) or the correct method names (seebelow), your score will be decreased by 50 points.§ In addition, deductions will be made for not meeting the following requirements:o At the beginning of each java file, add a comment with the following information:§ Student’s name§ Course/section,§ Date§ Filename§ Description of the program/classo Indentation guidelines:§ The code inside of a class must be indented with respect to the class definition.§ The code inside of a method must be indented with respect to the methoddefinition.§ The code inside of if / else / else if / while / for / do-while structures must beindented with respect to its corresponding structure.§ Curly braces can be positioned at the end of the corresponding structuredefinition, or in the following lines aligned with the corresponding structure.o Comments:§ At least, one-line comment should be added per method or constructor.§ Comments must describe the functionality or objective of the method.§ Please add more comments about your code, if you think that will help thegrader.CSE 271, Object-Oriented Programming, Spring 2018Homework 04, 100 pointsDue Saturday, March 3, 2018 by 11:59 pmRubricFull credit Partial creditImplement the PersonSolution(25 points)You implements the PersonSolution.You implements thePerson Solution, butwith some errors.Implement the DistanceSolution( 40 points)You implements the DistanceSolution.You implements theDistance Solution, butwith some errors.Implement the RectangleSolution(35 points)You implements the RectangleSolution.You implements theRectangle Solution, butwith some errors.CSE 271, Object-OrienteJava代写ArrayList Homework 代写Java课程设计、Java编程代写d Programming, Spring 2018Homework 04, 100 pointsDue Saturday, March 3, 2018 by 11:59 pmDescriptionThis assignment consists of the development of three solutions. Each solution should be stored in itsown folder. Submit the solution folders in a zip file, named Homework04.zip , to the correspondingassignment in Canvas.PersonSolution1. Create a project named PersonSolution .2. Using the descriptions provided in exercise P9.8 in the textbook, generate the three classes andtheir corresponding methods.3. These classes should be packed under the school package4. Define the class person as an abstract class.5. Write a program to test the Instructor and Student classes only. The name for the testprogram should be PersonTest .6. In this program, create individual objects for the Instructor and Student classes. Provide thenecessary information for each object. Then, test each class individually and display its outputusing the method toString .Sample run== Person Solution ==school.Student[name=Mikasa Ackerman,year=1935,major=Computer Science]school.Instructor[name=Levi,year=1920,salary=5000]DistanceSolution1. Create a project named DistanceSolution .2. Create a class named distance .3. Include that class in a package named metrics .4. Inside the class distance, create two static methods named manhattanDistance andeuclideanDistance .5. The method manhattanDistance receives as parameters two Double array lists.a. If the the two lists do not contain the same number of elements, this method returns -1b. Otherwise, the method shoud calculate the Manhattan distance between the twovectors and return it as a double value.c. For more information about how to calculate the Manhattan distance between twovectors, see 6. The method euclideanDistance receives as parameters two Double array listsa. If the array lists do not contain the same number of elements, this method returns -1b. Otherwise, the method shoud calculate the Euclidian distance between the two vectorsand return it as a double value.CSE 271, Object-Oriented Programming, Spring 2018Homework 04, 100 pointsDue Saturday, March 3, 2018 by 11:59 pmc. For more information about the Euclidean distance, see7. Create a program for testing these methods. Name this program DistanceTest .8. In DistanceTest ,a. Create two numerical array lists of size 3. Provide double values for these array lists.b. Display the content of these array lists.c. Display the Manhattan distance between these vectors (array lists) by calling themethod manhattanDistance .d. Create other two numerical array lists of size 5. Provide double values for these arraylists.e. Display the content of these array lists.f. Display the Euclidian distance between these vectors (array lists) by calling the methodeuclideanDistance .Sample run== Distance Solution ==Vector 1: [ 5.0, 6.7, 11.0]Vector 2: [ -9.0, 8.0, 0.3]Manhattan distance between vector 1 and vector 2: 26.00Vector 3: [ 0.5, 6.0, -2.0, 4.12, 15.6]Vector 4: [ -10.0, 8.6, 0.001, 9.2, 4.0]Euclidean distance between vector 3 and vector 4: 16.77RectangleSolution1. Create a project named RectangleSolution .2. The class java.awt.Rectangle does not contain a method to calculate the area of a Rectangleobject; also it does not implement the interface Comparable .3. Create a subclass of the Rectangle class named ComparableRectangle which also implementsthe Comparable interface.4. Include that class in a package named geometry .5. Create a constructor which receives two parameters width and height . Use these parametersto initialize the corresponding instance variables in the ComparableRectangle object.6. Create a public method named getArea which returns the area of the ComparableRectangleobject.7. Implement the method compareTo . Remember that this method receives anotherComparableRectangle as parameter.8. Create a program for testing this class. Name this program RectangleTest .CSE 271, Object-Oriented Programming, Spring 2018Homework 04, 100 pointsDue Saturday, March 3, 2018 by 11:59 pm9. In RectangleTest ,a. Create three ComparableRectangle objects. The first and secondComparableRectangle objects will have the same width and height. The thirdComparableRectangle will have a different witdh and height.b. Display the measures of these ComparableRectangle objects by using the methodtoString .c. Also, display the result obtained by comparingi. First ComparableRectangle with second ComparableRectangle .ii. First ComparableRectangle with third ComparableRectangle .iii. Third ComparableRectangle with second ComparableRectangle .Sample run== Comparable Rectangle Solution ==Rectangle 1: geometry.ComparableRectangle[x=0,y=0,width=5,height=8]Rectangle 2: geometry.ComparableRectangle[x=0,y=0,width=5,height=8]Rectangle 3: geometry.ComparableRectangle[x=0,y=0,width=11,height=2]Compare Rectangle 1 to Rectangle 2: 0Compare Rectangle 1 to Rectangle 3: 18Compare Rectangle 3 to Rectangle 2: -18转自:http://ass.3daixie.com/2018052516413957.html

你可能感兴趣的:(讲解:JavaArrayList Homework Java、Java)