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 Program 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 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 toStringParallelogram class: This class inherits from Trapezoid No instance variables Constructor accepts the 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 sets of coordinates to pass to the super class toString methodSquare class: This class inherits from Parallelogram Constructor that accepts the 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 toStringSample output:Coordinates of Quadrilateral are: Coordinates of Trapezoid are:Height is: Area is: Coordinates of Parallelogram are:Width is: Height is: Area is: Coordinates of Rectangle are:Width is: Height is: Area is: Coordinates of Square are:Side is: Area is: Grading Criteria: points quadrilateral creates four points in constructor points quadrilateral has two methods for output one to format the string and then the toString calls the format method points classes use inheritance properly in constructors, method header and toString points parallelogram calculates width points trapezoid calculates width points trapezoid calculates area 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
