0% found this document useful (0 votes)
8 views2 pages

Lab 8

The document outlines a programming task focused on multi-level inheritance in object-oriented programming, specifically involving geometric shapes like Quadrilateral, Trapezoid, Parallelogram, Rectangle, and Square. It details the requirements for defining classes, including methods for validating points, calculating areas, and printing shape information. Additionally, it emphasizes the need for test cases to validate the functionality of the implemented classes.

Uploaded by

bcsf23m511
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Lab 8

The document outlines a programming task focused on multi-level inheritance in object-oriented programming, specifically involving geometric shapes like Quadrilateral, Trapezoid, Parallelogram, Rectangle, and Square. It details the requirements for defining classes, including methods for validating points, calculating areas, and printing shape information. Additionally, it emphasizes the need for test cases to validate the functionality of the implemented classes.

Uploaded by

bcsf23m511
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab 8 (50 points)

Object Oriented Programming

Task 1: Multi-level Inheritance

1. Write a multi-level inheritance for classes Quadrilateral, Trapezoid, Parallelogram,


Rectangle and Square. Use Quadrilateral as the super class of the hierarchy. Specify the
instance variables and methods for each class. The protected instance variables of
Quadrilateral should be the x-y coordinate pairs for the four endpoints of the Quadrilateral.
2. Provide a function getPoints( ) that takes input from user for all four points starting from
bottom-left point in anti-clockwise fashion.
3. Provide a function validatePoints(Point p1, Point p2, Point p3, Point p4) to check if
provided points are valid for the particular shape. The points from p1 to p4 represent
bottom-left to top-left points in anti-clockwise manner.
4. Override this function in each class as each shape has its own requirements of valid points.
If invalid input is provided, then appropriate message will be shown and points will be set
to 0.
5. Provide a function that prints the information of a shape and its area (except Quadrilateral).
Override this function in each derived class.
6. Write a program that instantiates objects of your classes and outputs each object’s
information.

Hints:
 Create and use a Point struct to represent the corners of the shapes.
 Provide two test cases for each shape. One for valid set of points, one for invalid set of points.
 Your output for valid set of points should appear as follows:

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.0
Area 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.0
Height is: 15.0
Area 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.0
Height is: 14.0
Area 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.0
Area is: 16.0
General Information:

You might also like