Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

plaese write the code in C++ language S/OOP%20Assignment%203%20inheritanec%20and%20%20Polymorphism%202020-2021%20(4).pdf Task (Static, Composition, inheritance, and Polymorphism) Part 1 In a university system, employees can be categorised into:

plaese write the code in C++ language image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
S/OOP%20Assignment%203%20inheritanec%20and%20%20Polymorphism%202020-2021%20(4).pdf Task (Static, Composition, inheritance, and Polymorphism) Part 1 In a university system, employees can be categorised into: academics and administrators. However, all employee share common attributes: ID, Name, Hire_Date, and salary. The Academics can have the additional attribute Teaching_load (hours), teaching allowance. The administrators have the additional attributes: job_title admin_allowance. Note:_name and job_title are of type string, ID is const int, it is given a serial number starting from 20000 200002, 200003, and so on. Salary, admin_allowance, Teaching_load and teaching allowance of typ double. Hire_Date is of type Date (you have to write simple class Date) * Declare all data attributes as private Given below the classes declarations * Separate class interface and implementation 1) Create the base class Employee with the following functionalities: a) A constructor to initialize the data members and a virtual destructor b) A set function named set_values to change the Name, Hire_Date, and salary c) A function named print to display the details of Employee d) A virtual function named calaculate_salary ( this returns the salary) e) A pure virtual function void set_values const string , double) to act as an interface to access set_values i class Administrator, in case of Polymorphism 2) Create derived class Administrator with the following functionalities: a) A constructor to initialize the data members and a destructor b) A set function to change the job_title and admin_allowance c) A function named print to display all details including the one from the base class d) A function named calaculate_salary (this returns admin_allowance + salary). Hint: call calculate_salary function in base class to get salary 3) Similarly create class Academic include pads/O0P%20Assignment%203%20inheritanec%20and%20%20Polymorphism%202020-2021%20(4).pdf 3) Similarly create class Academic #include #include using namespace std; class Date private: int day, month, year; public: Date (int=1, int=1, int=1935); -Date(); void print ()const; 1; Date::Date (int x, int y, int 2) { day=x; month-ya year-z; 3 Date: :-Date()) void Date: :print() const! cout using namespace std; class EducationAcademy public: EducationAcademy (int size); // size is number of employees in the EducationAcademy EducationAcademy fint size, string Loc, const Date & D): -EducationAcademy 0); void Read_Current_Staff (); double Get TotalSalaries(); void Print_Current_Staff (); Employee - ReadOne Employee(); private: Employee . Current_Staff (100); // to allocate a maximum of 100 Employees int no_of_Current_Staff; it should not exceed 100 string Location: 71 default value "PSUT Date start Date; // default 1/1/2000 In ReadOneEmployee function the user will have two choices 'A' for Academic andi's' for Administrato Based on this choice the user will enter data and allocate an object based on that and return its address. Read_Current_Staff function will use the array of pointers Current_Staff and call ReadOne Employee number of times based on no_of_Current_Staff. This means that a pointer will be pointing at the objec created by ReadOne Employee function. Constructors will initialize the data attributes. Make sure the no_of_Current_Staff does not exceed 100 make it zero if incorrect size was used. Hint: call Read_Current_Staff function. Print_Current_Staff function will print the details of objects allocated by Current_Staff that have salarie between 2000 and 5000. Destructor will deallocate the objects according to the following order. Deallocate all objects with salarie below 1000 , followed by objects with salaries below 2000, and then deallcaote all objects that haw salaries above 5000. Then count the number of remaining objects Part 2 Write a program that defines an array of Education Academy pointers of size 5 named OOP_academies. Based on user input allocate dynamically the number of academies according to the size entered by the user for each EducationAcademy object. Print all employees of the allocated OOP_academies. Do any necessary deallocations. ads/OOP%20Assignment%203%20inheritanec%20and%20%20Polymorphism%202020-2021%20(4).pdf public: EducationAcademy (int size); // size is number of employees in the EducationAcademy EducationAcademy (int size, string Loc, const Date & D): -EducationAcademy (); void Read_Current_Staff (); double GetTotalSalaries(); void Print_Current_Staff (); Employee ReadOne Employee (); private: Employee . Current_Staff [100]; to allocate a maximum of 100 Employees int no_of_Current Staff; it should not exceed 100 string Location; 7 default value "PSUT Date start_Date: y default 1/1/2000 In ReadOne Employee function the user will have two choices 'A' for Academic and 'B' for Administrator. Based on this choice the user will enter data and allocate an object based on that and return its address. Read_Current_Staff function will use the array of pointers Current_Stoff and call ReadOneEmployee a number of times based on no_of_Current_Staff. This means that a pointer will be pointing at the object created by ReadOneEmployee function. Constructors will initialize the data attributes. Make sure the no_of_Current_Staff does not exceed 100, make it zero if incorrect size was used. Hint: call Read_Current_Staff function. Print_Current_Staff function will print the details of objects allocated by Current_Staff that have salaries between 2000 and 5000. Destructor will deallocate the objects according to the following order. Deallocate all objects with salaries below 1000, followed by objects with salaries below 2000, and then deallcaote all objects that have salaries above 5000. Then count the number of remaining objects Part 2 Write a program that defines an array of Education Academy pointers of size 5 named OOP_academies. Based on user input allocate dynamically the number of academies according to the size entered by the user for each EducationAcademy object. Print all employees of the allocated OOP_academies. Do any necessary deallocations

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Is an entity relationship diagram used to capture process flows?

Answered: 1 week ago