0% found this document useful (0 votes)
22 views

Object Oriented Programming Lab Manual (Lab 02) : Topic: Basic Class and Setters/Getters

A Thousand Splendid Suns-Riverhead Books (2007)

Uploaded by

Mr. Nasrullah
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)
22 views

Object Oriented Programming Lab Manual (Lab 02) : Topic: Basic Class and Setters/Getters

A Thousand Splendid Suns-Riverhead Books (2007)

Uploaded by

Mr. Nasrullah
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/ 3

Object Oriented Programming

Lab Manual (Lab 02)

Topic: Basic Class and Setters/Getters


Course Instructor: Dr. Asma Naseer
Lab Instructor: M.Waheed Waqar

Session: s2021

School of Systems and Technology


UMT Lahore Pakistan
Task01
Develop a class Employee for storing the employee information. The employee object can
contain following Data Members:
 Employee ID ( integer)
 Name ( string)
 Designation ( string)
 Pay Scale (integer, must be a number between 1-20)

Class should have following member functions:


Getter, setter for all data members. Keep the data members private.
Output function: displays ID, name, designation and pay scale of current employee.

1)
Then write main function and create 3 Employee objects with following information, and display
this information as output on screen.
1. 1, Ali, Sales Person, 10 (id,name,designation,pay scale)
2. 2, Babar, Manager, 17
3. 3, Sarwar, IT Administrator, 16

2)
Create other 3 Employee objects and take these three employees information from user, and
display this information as output on screen.

3) update the designaton of Babar from manager to sale person and also update his pay scale
from 17 to 10. And display updated babar information on screen.

Task02
a)You have to create a class Date that has 3 private member variables to store following three
attributes:
day (int)
month (int)
years (int)

b) Implement the getter and setter functions for each of the above three member variables.
Names of these functions setDay, setMonth, setYear, getDay, getMonth,getYear with proper
checks.
c) Implement a public member function displayDate of the Date class. This function should
display the date in the following format. For example, the date 15th March 2016 should be
displayed on screen like 15/03/2016
e) Write a main function to test the working of Date class and its member functions.
f) In the main function, create 5 Date objects. Store these five dates in these Date objects:
25-12-1876
9-11-1877
21-08-1938
14-08-1947
11-03-1948
(Note: use setters functions to set the date values)

Now, print these five dates by calling the appropriate member function of the Date class.
(Note: use getters functions to display in main functions)

You might also like