Question: Hi, I am doing an assignment which requires creating a MyPoint object(in the first pic), and a rectangle object(in the second pic) and then using

 Hi, I am doing an assignment which requires creating a MyPoint

object(in the first pic), and a rectangle object(in the second pic) andthen using a test class to see if the methods are working

Hi, I am doing an assignment which requires creating a MyPoint object(in the first pic), and a rectangle object(in the second pic) and then using a test class to see if the methods are working and being passed throughout the package. I am having trouble with getting the MyPoint objects to be passed into the rectangle class and then having the area be computed. I am wondering if anyone knows how to solve this question.

=== Exercise 2: Start by making the class Rectangle as described in problem 9.1 from Chapter 9. 9.1 (The Rectangle class) Following the example of the Circle class in Section 9.2, design a class named Rectangle to represent a rectangle. The class contains: Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height, A no-arg constructor that creates a default rectangle. A constructor that creates a rectangle with the specified width and height. A method named getArea() that returns the area of this rectangle. A method named getPerimeter() that returns the perimeter. Draw the UML diagram for the class then implement the class. Write a test pro- gram that creates two Rectangle objectsone with width 4 and height 40, and the other with width 3.5 and height 35.9. Display the width, height, area, and perimeter of each rectangle in this order. Add an instance method named compareAreal) to compare the calling rectangle object to another rectangle object and return a boolean true if the areas of the two rectangles are equal. Add a method named includesPoint(MyPoint point) that takes a MyPoint object and tests to see if it is inside the rectangle. The assumption is that the center of the rectangle is at the origin (0, ). Add a Constructor that takes two MyPoint objects as the topleft and bottom right corners of the rectangle. *You do not have to do the UML part of the exercise. ======== This is the test class that will be used to validate that your Class Objects are working. Don't change this class! === Exercise 2: Start by making the class Rectangle as described in problem 9.1 from Chapter 9. 9.1 (The Rectangle class) Following the example of the Circle class in Section 9.2, design a class named Rectangle to represent a rectangle. The class contains: Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height, A no-arg constructor that creates a default rectangle. A constructor that creates a rectangle with the specified width and height. A method named getArea() that returns the area of this rectangle. A method named getPerimeter() that returns the perimeter. Draw the UML diagram for the class then implement the class. Write a test pro- gram that creates two Rectangle objectsone with width 4 and height 40, and the other with width 3.5 and height 35.9. Display the width, height, area, and perimeter of each rectangle in this order. Add an instance method named compareAreal) to compare the calling rectangle object to another rectangle object and return a boolean true if the areas of the two rectangles are equal. Add a method named includesPoint(MyPoint point) that takes a MyPoint object and tests to see if it is inside the rectangle. The assumption is that the center of the rectangle is at the origin (0, ). Add a Constructor that takes two MyPoint objects as the topleft and bottom right corners of the rectangle. *You do not have to do the UML part of the exercise. ======== This is the test class that will be used to validate that your Class Objects are working. Don't change this class! Eceis- W3Cws Otero X Cushbu X C G Hotewark Hero With Chey x + C calstatela instructure com/courses/58622/pages/exercises weck class objets?module_item_id-3053076 amazon.com: Onlin.. G GoogcCawas Network crocs Git-u - Sicam2 Mcg - Kits Rescue npps Lala La Login LA PACKAUM MITE; tnport coretrvciacs.roint: oncert scoretryclass. Rectangle puiktir la intel public static void ministrinel args) double wicth - 2.71; double height 8.3; 24 My in polet Paint() Most point- new ypaint (1.1. 9. 1): Nyloant pourt - Noint(7.1, 2.2); Q" System.out.println("x" + point.getX()+"y"+int-LY); Sx.l.println("lis-point lliscamins Systout.printing distance pointi.distance(4.v. 0.5)): System.out.printindistance Hypoint.distance point, pointa): Rectangle rect me Rectangles Bulu - Hellwidth, heich; Rectangle rec! - PK Hectangle(2.13.1.1): Rectanglo reci - new Rectanglo0.7, a.a): Rectangle rocs - new Rectangle(8.3, 2.71); Rettangle recome Rectangle(point2, points); Syst.ct.println("width-petish) + " height-1.gitight); System.out.println("area-' + igara) + porte moci.getvorotoro). System.out.printinadth-c2.gctwidth" height-rcc2.getHeight(1). System.out.println "area-Tec2.getarea) "perincter rec2.getPerister); System.out.println("wid.ch .cleWid) + ".reco.se Height(); ...println("APA-'-) "fer. Perier); Svetom.out.printin rcc2.conarcrcrcca): System.out.println(rec2.compares trec) System.out.println(ruc2.cdrc)); vystout.printlncres. Incluso (point): >

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!