Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Riphah International University

I-14 Main Campus


Faculty of Computing
Course Code: Subject: Object Oriented Programming
Lab Manuals Lab Instructor: Muhammad Islam

Question # 1:
Consider a base class Employee which contain basic information of an employee such as:
Name(string)
Address(string)
Id(int)
Gender(string)
Now create two constructors A default constructor to initialize the data member with
default values, A four-argument constructor to initialize data field with user-define
values( must use this key word). Getter and setter function to set and get values of data
fields.
Derives two classes to show Hierarchical inheritance .
A department class which extends the base class employee also have some its own
information such as:
Department Name(string)
Department Id(int).
Now create two constructors A default constructor to initialize the data member with
default values, A parameterized constructor to initialize data field with user-define
values. Appropriate getter and setter function to set and get values of data fields .A
display method to show all the records of employee along with department information.
Create another child class Loan which extends the base class employee and also have
some its own properties such as:
Loan Amount(float)
Loan type(string)
Now create two constructors A default constructor to initialize the data member with
default values, A parameterized constructor to initialize data field with user-define values
. Appropriate getter and setter function to set and get values of data fields .A display
method to show all the records of employee along with loan information.
In main class you have to create an object of employee class to set the values of the data
member with user define values(either through constructors or setter functions). An
object of department class to set the values of the data member with user define
values(either through constructors or setter functions)and call the display method. An
object of loan class to set the values of the data member with user define values(either
through constructors or setter functions)and call the display method.
Question # 2:
Create a class named GeometricShape containing
Two data fields
Riphah International University
I-14 Main Campus
Faculty of Computing
Course Code: Subject: Object Oriented Programming
Lab Manuals Lab Instructor: Muhammad Islam

shapeType (a string)
area (of type double)
A no-argument constructor to initialize all data fields with default values “NoShape” and
0.0 . A member function named show() to display the details associated with an instance
of this class . Derive a class named Rectangle from class GeometricShape that includes
Data members:
Length(int)
Width(int)
Respective mutater and accessor functions to set and get values of length and width, and
function named computeArea() to compute the area of rectangle (length x width) and
function named show() to display the details associated with an instance of class
Rectangle and also its shape type attribute from parent class .From the Rectangle class,
derive a class named Cuboid that contains A data field named height in addition to length
and width. A three arguments constructor to initialize the values (use super key word for
length and width).Two functions named setHeight() and getHeight() to set and get value
of height data field, and function named computeArea() to calculate the area of a cuboid
(length x width x height) And function named show() to display the details associated
with an instance of class Cuboid and also shape type attribute from Shape class.
Implement these classes and in the main class with main method create instances of each
class first set the values through setter function or constructors (take input from user).and
then call the computeArea() and show() methods of Rectangle and Cuboid class through
there instances.

You might also like