0% found this document useful (0 votes)
81 views3 pages

Object Oriented Programming LAB (06+07) Special OOP Section (NC) Instructions

This document provides instructions for two object-oriented programming lab tasks. Task 1 involves creating an Instructor class with private data members for ID, name, qualification, and salary. Students are asked to provide mutators, accessors, constructors, copy constructor, destructor, and member functions like set/get data and check qualifications. Task 2 involves creating a Date class with private data members for day, month, year. Students are asked to provide accessors, mutators, constructors, destructor, input/output functions, and overloaded operators like ==, !=, >, < for comparison and - for subtraction. Main functions must be written to test the classes.

Uploaded by

Asad Latif
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)
81 views3 pages

Object Oriented Programming LAB (06+07) Special OOP Section (NC) Instructions

This document provides instructions for two object-oriented programming lab tasks. Task 1 involves creating an Instructor class with private data members for ID, name, qualification, and salary. Students are asked to provide mutators, accessors, constructors, copy constructor, destructor, and member functions like set/get data and check qualifications. Task 2 involves creating a Date class with private data members for day, month, year. Students are asked to provide accessors, mutators, constructors, destructor, input/output functions, and overloaded operators like ==, !=, >, < for comparison and - for subtraction. Main functions must be written to test the classes.

Uploaded by

Asad Latif
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(06+07)

Special OOP Section(NC)

Instructions:

• Work on your own in the lab task. No collaboration is allowed; otherwise it would result
in 'F'. You can use your books, notes, handouts etc.
• To get full credit of your efforts, follow the coding conventions as well as the comments
section that describes your logic to the teacher assistant.
• Email the lab to the email [email protected] with a proper subject of following
format: [RollNum]-LAB(06+07)
• Main Objective: Revise the concepts

Task # 1:

1. ADT: Instructor : The class should have following five private data members
1. An int named id that holds the identification number. The value of identification number should fall
in between 1000 to 2000 both inclusive, 0 otherwise.
2. A string named firstName that holds the first name.
3. A string named lastName that holds the last name.
4. A string named qualification that holds the instructor’s qualification in which he/she mastered.
5. A float named salary that holds the instructor’s current monthly salary. The value of salary must fall
in between 20000.00 and 100000.00 both inclusive, -1 otherwise.

2. Provide the implementation of mutators for all the data members (id, firstName,lastName, qualification
and salary) of the class.

3. Provide the implementation of accessors for all the data members (id, firstName, lastName, qualification
and salary) of the class.

4. Provide the implementation of following constructors and a destructor.


1. Parameterized Constructor initializes instructor’s identification number, first name, last name and
qualification.

2. Constructor initializes instructor’s identification number, first name and qualification as arguments.

3. Constructor should accept the instructor’s identification number, first name, last name,
qualification and salary as arguments. These values should be assigned to the object’s appropriate
member variables.

1 OOP Special Section


[email protected]
4. A copy constructor to initialize instructor’s object with already existing object.
5. A destructor that do nothing except displaying a simple message “Destructor executed…” on the
screen.

5. Provide the implementation of following member functions


1. Set_all method initializes instructor’s identification number, first name, last name, qualification
and salary.

2. Get_data method to initialize the data of instructor’s taken from the user.
3. Write_data method to display the information of a particular instructor’s.
4. isPostGraduate method should return true if the instructor’s qualification is post graduated.i.e. a
instructor’s having MS or Phd. degree(s), false otherwise.

5. isJoined method should return true if the instructor’s salary is greater than or equal to 20000.00, false
otherwise.

Once you have written the class, write main function and test its functionality by creating some objects of
Instructor’s. (30 Marks)

Task # 2:

ADT: Date
Write a class named Date having following functionalities
1. The class should have following three private data members.
i. An integer named day that holds the day number of the month.
ii. An integer named month that holds the month number of the year.
iii. An integer named year that holds the year number.
Value should only be assigned to day, if it is in between 1 (default value) and 31 both inclusive.
Value should only be assigned to month, if it is in between 1 (default value) and 12 both inclusive.
Value should only be assigned to year, if it is in greater than or equal to 1900 (default value).

2. Provide the implementation of accessors and mutators.


3. Provide the implementation of following constructors and a destructor.
i. The constructor should accept the Date’s day, month and year as arguments. These values should
be assigned to the object’s appropriate member variables.

ii. A default constructor that initializes all the data members of the class with default values.

iii. A destructor that display’s message “Destructor Called”.

2 OOP Special Section


[email protected]
4. Date takeInput( ) should prompt the user for a date to be stored in a Date object. The operator should
ask the user to enter the date in the following format; dd/mm/yyyy
5. Void Display_date(Date &obj) that displays date in the form May 12,2015.

6. Provide the implementation of following overloaded operators


i. Equal to (==) should return true if two dates are same, false otherwise.

ii. Not Equal to (!=) should return true if two dates are not same, false otherwise.
iii. Greater than (>) should compare two dates and return the greater date. For example if May
12, 2015 is comapred with May 20, 2015 the result will be May 20, 2015.

iv. Less than(<)should compare two dates and return the smaller date. For example if May 12,
2015 is comapred with May 20, 2015 the result will be May 12, 2015.

v. subtraction (-) binary should subtract the one date from another and return the number of
days between two dates. For example, if May 12, 2015 is subtracted from May 20, 2015 the
result will be 8.

vi. addition (+) unary should return true, if the date is a public holiday (25 Dec,5 Feb, 23 March,
1 May etc.etc.), false otherwise.

vii. Stream Insertion (<<) operator that displays date in the form May 12,2015.

viii. Stream Extraction (>>) operator should ask the user to enter the date in the following format;
dd/mm/yyyy

7. Once you have written the class, write main function and test its functionality by creating some
objects of Date. (30 Marks)

3 OOP Special Section


[email protected]

You might also like