Question
Class name is Quadrilateral It has 4 private MyPoint object attributes, one for each corner of the quadrilateral (4 sided) shape. If you want to
Class name is Quadrilateral
It has 4 private MyPoint object attributes, one for each corner of the quadrilateral (4 sided) shape. If you want to you could use an array of MyPoints, it doesn't really matter because they are private.
Give it a no argument Constructor with default corner points (-1,1), (1,1), (1,-1), (-1,-1)
Include a Constructor that takes 4 MyPoint objects. Be aware that the Points may not be given is a usable order and the points will have to be adjusted as necessary.
Method named getArea() that returns the area.
Method named getPerimeter() that returns the total length of the perimeter.
Method named getCenter() that returns a MyPoint value for the center of the Quadrilateral object.
*hint on finding the intersection between two lines (make sure to include attribution to the source) https://tutorialspoint.dev/algorithm/geometric-algorithms/program-for-point-of-intersection-of-two-lines (Links to an external site.)
Method named getSides() that returns an array of doubles containing the length of each side in clockwise order, it does not matter which side is first..
Method named getCorners() that returns an array of MyPoints of the corner locations. the points will be in a order going clock wise (doesn't mater which corner is first). The order is not necessarily the same as was provided to the Constructor. make sure to deep copy the corner MyPoint objects before returning to make sure the Quadrilater Class is immutable and can not be changed using the returned MyPoint objects.
Method named contains(double x, double y) that takes a x and y doubles and returns if that location is inside the Quadrilateral.
Overloaded method named contains(MyPoint thing) that takes a MyPoint object and returns if that location is inside the Quadrilateral.
Overloaded method named contains(Quadrilateral thing) that takes another instance of a Quadrilateral object and returns if it is inside the calling Quadrilateral.
Method named overlaps(Quadrilateral thing) that returns true if the shapes overlap. Returns false if the other shape is completely inside or outside of the calling Quadrilateral instance.
Below is something that should help out with the above problem
package geometrytest; import geometryclass.MyPoint; import geometryclass.Rectangle; public class PointRectangleTest { public static void main(String[] args) { double width = 2.71; double height = 8.3; MyPoint point1 = new MyPoint(); MyPoint point2 = new MyPoint(4.1, 9.3); MyPoint point3 = new MyPoint(7.1, 2.3); System.out.println("x= " + point3.getX() + " y= " + point3.getY()); System.out.println("distance= " + point3.distance(point2)); System.out.println("distance= " + point3.distance(9.9, 0.3)); System.out.println("distance= " + MyPoint.distance(point1, point3)); Rectangle rec1 = new Rectangle(); Rectangle rec2 = new Rectangle(width, height); Rectangle rec3 = new Rectangle(2.71, 8.3); Rectangle rec4 = new Rectangle(2.7, 8.3); Rectangle rec5 = new Rectangle(8.3, 2.71); Rectangle rec6 = new Rectangle(point2, point3); System.out.println("width= " + rec1.getWidth() + " height= " + rec1.getHeight()); System.out.println("area= " + rec1.getArea() + " perimeter= " + rec1.getPerimeter()); System.out.println("width= " + rec2.getWidth() + " height= " + rec2.getHeight()); System.out.println("area= " + rec2.getArea() + " perimeter= " + rec2.getPerimeter()); System.out.println("width= " + rec6.getWidth() + " height= " + rec6.getHeight()); System.out.println("area= " + rec6.getArea() + " perimeter= " + rec6.getPerimeter()); System.out.println(rec2.compareArea(rec3)); System.out.println(rec2.compareArea(rec4)); System.out.println(rec2.compareArea(rec5)); System.out.println(rec2.includesPoint(point3)); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started