0% found this document useful (0 votes)
7 views1 page

OOP Lab Mid 2

The document outlines the Mid Semester Examination for the Object Oriented Programming Lab at Air University, scheduled for April 3, 2024. It includes instructions for a closed-book exam with compulsory questions, focusing on developing a C++ program that models geometric entities using classes for Point, Line, and Triangle. The program requires the implementation of constructors and methods for calculating lengths and areas within a hierarchical inheritance structure.

Uploaded by

huzaifaltaf605
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)
7 views1 page

OOP Lab Mid 2

The document outlines the Mid Semester Examination for the Object Oriented Programming Lab at Air University, scheduled for April 3, 2024. It includes instructions for a closed-book exam with compulsory questions, focusing on developing a C++ program that models geometric entities using classes for Point, Line, and Triangle. The program requires the implementation of constructors and methods for calculating lengths and areas within a hierarchical inheritance structure.

Uploaded by

huzaifaltaf605
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/ 1

Air University

Mid Semester Examination Spring 2024


Student Id:
Subject:-Object Oriented Programming Lab Total Marks:- 30
Course Code: - CS112L Date:-03 April,2024
Class:-BSAI Time:- 11:00 -13:00
Semester:-II Max Time Allowed: 1 hr.
Section(s):-A FM(s) Name:-Ms. Umm-e-Sadima
FM Signature:

Special Instructions:
• There is no choice in the paper, and all question are compulsory.
• The exam is closed-book paper.
• Students must not use the cell phone in the exam.
Question #1: [CLO-1]

Write a C++ program for all the classes mentioned below:

Develop a C++ program to model geometric entities in a 2D plane, incorporating


inheritance for a hierarchical relationship.

1. Begin by defining a Point class to represent points with x and y coordinates.


This class should include a constructor to initialize the point with given x
and y coordinates, along with a default constructor to set the point's
coordinates to (0, 0) by default.
2. Next, create a Line class to represent line segments on the plane,
characterized by a start point and an end point. The Line class should
include a constructor to initialize the line with specified start and end points,
as well as a method to calculate and return the length of the line segment.
3. Finally, extend the Line class to form a Triangle class, which represents
triangles composed of three lines: base, height, and hypotenuse. The
Triangle class should inherit from the Line class and include a constructor to
initialize the triangle with given base, height, and hypotenuse lines, along
with a method to compute and return the area of the triangle.

You might also like