Question: Inheritance Program 5 0 pointsWrite a program that contains classes for Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Create and use a Point class to represent

Inheritance Program50 pointsWrite a program that contains classes for Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Create and use a Point class to represent the points in each shape.Point class: This class contains an x and y variable to represent coordinates. Create a custom constructor that accepts the coordinates, getters for each and a toString method.Quadrilateral class: This class contains four variables, which are each points. The constructor will accept 4 sets of coordinates and create points for these coordinates and assign the points to the instance variables. Create getters for the four points and a toString. In addition, create a method named getCoordinatesAsString which formats the coordinates which will be called by the toString method.Trapezoid class: This class inherits from Quadrilateral.Instance variable: heightMethods: Constructor: accepts the four sets of coordinates that will then be passed to the Quadrilateral constructor. getHeight()- This method calculates the height based on the y coordinates of two points. getSumOfTwoSides()- This method determines the length of two sides and returns the sum of these two lengths getArea()- This method calculates the area of the trapezoid by calling the getSumOfTwoSides and multiplying that result by height divided by 2 toStringParallelogram class: This class inherits from Trapezoid No instance variables Constructor accepts the 4 sets of coordinates to pass to the super class getWidth()- This method calculates the width based on the x coordinates of two points toStringRectangle class: This class inherits from Parallelogram No instance variables Constructor that accepts the 4 sets of coordinates to pass to the super class toString methodSquare class: This class inherits from Parallelogram Constructor that accepts the 4 sets of coordinates to pass to the super class toString method Rectangle class: This class inherits from Parallelogram- Create a constructor and a toStringDriver: Create one instance of each type of object: Quadrilateral, Trapezoid, Parallelogram, Rectangle, Square and then output each, calling the toString().Sample output:Coordinates of Quadrilateral are:(1.1,1.2),(6.6,2.8),(6.2,9.9),(2.2,7.4) Coordinates of Trapezoid are:(0.0,0.0),(10.0,0.0),(8.0,5.0),(3.3,5.0)Height is: 5.0Area is: 36.75 Coordinates of Parallelogram are:(5.0,5.0),(11.0,5.0),(12.0,20.0),(6.0,20.0)Width is: 6.0Height is: 15.0Area is: 90.0 Coordinates of Rectangle are:(17.0,14.0),(30.0,14.0),(30.0,28.0),(17.0,28.0)Width is: 13.0Height is: 14.0Area is: 182.0 Coordinates of Square are:(4.0,0.0),(8.0,0.0),(8.0,4.0),(4.0,4.0)Side is: 4.0Area is: 16.0 Grading Criteria:5 points- quadrilateral creates four points in constructor5 points- quadrilateral has two methods for output- one to format the string and then the toString calls the format method10 points- classes use inheritance properly- in constructors, method header and toString5 points- parallelogram calculates width5 points- trapezoid calculates width10 points- trapezoid calculates area10 points- Correct instantiation and output of objects

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 Programming Questions!