Question: In Java For both exercises the Classes have to be in a package named 'geometryclass' Round all double values to 4 decimal places. =========================================================================================== Exercise

In Java For both exercises the Classes have to be in a package named 'geometryclass'

Round all double values to 4 decimal places.

===========================================================================================

Exercise 1:

Write the Class for MyPoint from problem 10.4 from Chapter 10).

Distance Formula: Given the two points (x1, y1) and (x2, y2), the distance d between these points is given by the formula:

d=(x2x1)2+(y2y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2\,}

for two points (p1x, p1y) and (p2x, p2y) distance = Math.sqrt(Math.pow( ( p1x - p2x ), 2) + Math.pow(p1y - p2y, 2))

==============================================================================================

Exercise 2:

Start by making the class Rectangle as described in problem 9.1 from Chapter 9.

Add an instance method named compareArea() 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, 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.

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!