Question: Java inheritance question, you can ignore the red box referencing part 1. In this problem, you are provided with a Shape class and will need

 Java inheritance question, you can ignore the red box referencing part1. In this problem, you are provided with a Shape class andwill need to create the other four classes shown in the followingclass hierarchy. Each shape object has one (x,y) coordinate that anchors it

Java inheritance question, you can ignore the red box referencing part 1.

In this problem, you are provided with a Shape class and will need to create the other four classes shown in the following class hierarchy. Each shape object has one (x,y) coordinate that anchors it in the xy plane. This anchor point is fixed and cannot change once an object is created. The other parameters can change though. The provided XYCoord class is used to store (x,y) coordinates. All shapes must be able to compute their own area and perimeter 1 in addition to specific methods (outlined below). You are free to add any state to your classes as needed but you should not be storing information twice. Each of the classes will have a constructor that is appropriate for the particular shape detailed as follows: public Quadrilateral(XYCoord a, XYCoord b, XYCoord c, XYCoord d) // a quadrilateral has four straight sides and four corner points (vertices) // the corner points are specified by the inputs a,b,c,d // a is the anchor coordinate for this shape. public square(XYCoord anchor, double length) // a square is a special quadrilateral (all sides have the same // length and the angle at each corner is 90 degrees). // the anchor is the bottom-left corner of the square and length >=0 public Triangle(XYCoord a, XYCoord b, XYCoord c) // a,b, c are the three coordinates of the corners (vertices) of the triangle // a is the anchor coordinate for this shape public Circle(XYCoord centre, double radius) // centre is the anchor coordinate and radius >=0 You will also need to create the following setter methods in the specified classes. Note that there is no setter for the Quadrilateral class.: Circle Class public void setRadius(double newRadius) // changes the object's radius to be newRadius Triangle Class public void setBC(XYCoord newB, XYCoord newC) // changes the object's b and c points to be newB and newC Square Class public void setLength(double newLength) // changes the object's length to be newLength You can use the provided ShapeExampleApp to help test your code. Do NOT change or submit the provided Shape.java file. Do NOT change or submit the provided XYCoord.java file. When testing, we will use the files as provided (and delete any version you submit). The area for the square and circle should be straightforward to compute. For the quadrilateral, note that you can think of this shape as being composed of two triangles next to each other. For a triangle, you might find the following resource helpful: https://byjus.com/maths/ area-of-a-triangle/ Note that the shapes will always be created with coordinates as shown below. That is, the ordering of the coordinates will correspond to the labelling on the diagrams

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!