Object Oriented Programming LAB (06+07) Special OOP Section (NC) Instructions
Object Oriented Programming LAB (06+07) Special OOP Section (NC) Instructions
LAB(06+07)
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.
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.
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).
ii. A default constructor that initializes all the data members of the class with default values.
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)