Sie sind auf Seite 1von 2

Assignment 3 Semester 2 OOCP

1. Write a program that creates a binary file that contains the record of employees.

Display the records of employees in forward or backward directions as per user choice. ( Note: Define class employee which contains appropriate information related to employees).Also use exception handling if the record does not exists. 2. Write a program to read a file that consists of integers. Split the file into 2 files. Both the file contains the alternate numbers from the first file. 3. Write a program that reads a text file and creates another file that is identical except that sequence of consecutive blank spaces is replaced by single space.
4. Define a Generic Stack class. Declare an object of Stack that can work with int

values as well as for objects of Journal class. And call the functions of push, pop, display and pop for both the stack objects.
5. Define a class Employees. Also define classes of MaleEmp and FemaleEmp

inheriting from that. Define classes Officers, Clercks and peons again inheriting from Employee class. Define an array which contains 10 different types of employees. Define a function ReadDetails() in all above classes. All array elements should be able to be accessed in the same routine irrespective of their type. 6. Create a Fruit class which works as a base for several derived classes for fruit types such as Apples, Oranges, Pears, etc. Include methods in Fruit class that provides properties of the fruit such as the color (e.g. String gecolor()), shape, average weight, etc. The derived class will override these methods to provide the

properties unique to a particular fruit. For one of the classes, e.g Pear, create subclasses for particular types, such as Bartlet and Anjou pears. In the main( ) routine, create instances of the different fruit classes and invoke methods that print out the attribute values such as color, shape, etc. 7. Create a class Employee with the attributes name, address, date-of-birth, and salary etc., Include the function to set and get the values of attributes, which should be declared virtual. Inherit this class to create class Manager and Clerk. Include the function to set and get values, which calls the base class function. Create an array of pointers to the class Employee. Depending upon users choice for creating a Manager or Clerk, objects must be created. 8. Create a class Cricketer that holds the name, date-of-birth, no-matches etc., of each Cricketer. Include the virtual functions to set and retrieve values. Inherit the class Cricketer to create a class Batsman that stores the number of 100s, 50s of the batsman and a class Bowler that holds the total-wickets, no-of-maiden-overs of the bowler. Include function to set and retrieve values in both classes.
9. Define a class Variables. It should contain the variable name, its type, the index

in the symbol table and constructors and destructors. Inherit that into the SystemVariable and UserVariable. SystemVariable indicates the system process which has generated that variable. UserVariable indicates the user id which initiated that variable. Define CompilerVariable using multiple inheritance from SystemVariable and UserVariable. Define a pointer to Variable class and use dynamic cast to downcast it to a variable of type SystemVariable. Provide error message using exception handling if dynamic cast fails.

Das könnte Ihnen auch gefallen