Question: Please code in java Exercise 1A First define a Point class as follows: Double data fields px and py that specify the x and y

Please code in java

Please code in java Exercise 1A First define a Point class asfollows: Double data fields px and py that specify the x andy coordinates of the point. A constructor that sets an instance of

Exercise 1A First define a Point class as follows: Double data fields px and py that specify the x and y coordinates of the point. A constructor that sets an instance of the Point with the given px and py values. Getters and Setters A toString method to display the data fields. Next define a Rectangle class as follows: Double data fields named xpos, ypos (that specify the top left corner of the Rectangle), width and height. (as in Examples A and 0B, assume that the Rectangle's sides are parallel to the x and y axes. See example below) (0.0,0.0) xpos, ypos = (1.0, 1.0) height = 2.0 width = 3.0 A constructor that creates a rectangle with the specified xpos, ypos, width, and height. Get and set methods for all the instance variables. A toString method to display the data fields. A method contains (Point p) that returns true if a Point object is contained in this Rectangle. The method should return true even if the Point touches the sides of the Rectangle. . An example is shown below. Recall that you solved a similar problem in the lectures. (0,0) 05 1 2 3 4 0.5 (05,05) 1 3 (4,1) (4,2) 2 2 (2.2) 3 (4,3) (13) 4 (3.4) Then define a class called Demol that works as follows. . It defines a rectangle different from the example given above, and displays the data fields. Defines three points with the following properties, and displays the data field. A point p1 lies inside of the rectangle. o A point p2 touches the side of the rectangle. o A point p3 lies outside of the rectangle. Calls contains (Point p) method, and this method must correctly identifies whether each one of these points is contained in the rectangle. Finally, provide the complete console output of the above three test cases (p1, p2, p3). A sample dialog and output is given below. Created one rectangle object: [xpos = 1, ypos = 1] width: 3, height: 2 Created a point object: p1 [xpos = 2, ypos = 2] Created a point object: p2 [xpos = 4, ypos = 2] Created a point object: p3 [xpos = 0.5, ypos = 0.5] Is p1 contained in the rectangle? true Is p2 contained in the rectangle? true Is p3 contained in the rectangle? false Marking rubric . 0.25 mark is deducted for missing one test case. . 0.25 mark is deducted for not displaying data fields

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!