讲解: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

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 205,236评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,867评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,715评论 0 340
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,899评论 1 278
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,895评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,733评论 1 283
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,085评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,722评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,025评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,696评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,816评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,447评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,057评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,009评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,254评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,204评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,561评论 2 343

推荐阅读更多精彩内容