Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I really could use help on my last C++ project on Inheritance and Polymorphism! - Objective: The main goal of this last project is to

I really could use help on my last C++ project on Inheritance and Polymorphism!

-

Objective: The main goal of this last project is to implement a simple inheritance hierarchy between the Person and Employee class.

-

Description: Declare and implement the Employee class as a derived class of the Person class, which is already implemented in the demo codes pasted at the bottom of this post. Note that your project doesn't need to include the Student class. Please also feel free to modify the Person class. For instance, you can replace the data type for birthday to string.

-

Specifically, your project will include Person as the base class, and Employee as the derived class of Person. Your Employee class will include the following data members:

1. year of employment (e.g., 2012)

2. base salary

3. a dynamic array to keep track of the annual salary increase rate since the year of employment. For instance, an employee joined the company in year 2013, his salary increase rates in 2014, 2015, and 2016 were 10%, 7%, and 11%, respectively. This dynamic array will then hold the following three numbers: 0.1, 0.07, and 0.11. Furthermore, let bSal be the base salary, the current salary of the above employee should be equal to: bSal*1.10*1.07*1.11. Note that although the size of this array is derivable from the year of employment, you are recommended to include two additional data members to manage the capacity and size of this array.

-

At the minimum, your Employee class needs to include the following function members:

- a default constructor

- the Big-3: destructor, copy constructor and overloaded assignment operator

- an accessor to return the current salary of an employee

- an accessor and mutator for each of the above data members. It's sufficient to return the salary increase rate in a specific year.

- an overloaded put operator (

- override the output() function in the base class, as this function is virtual in Person.

-

Please provide a simple character-based interface to allow the user to test each of the above member functions. Make sure you test the output() function using Person pointers and observe polymorphism in action.

-

Submission requirements: Please use separate compilation and submit your source code into one zip file. Your project will include two header files (one for the Person class, the other for the Employee class) and three .cpp files. Because this is Chegg, you only need to copy and paste your code for the five files in your post. Thank you!

-

Demo Codes:

-

DayOfYear.h

image text in transcribed-

DayOfYear.cpp

image text in transcribed-

Person.h

image text in transcribed-

Person.cpp

image text in transcribedimage text in transcribedimage text in transcribed-

Personnel.cpp

image text in transcribedimage text in transcribed-

Student.h

image text in transcribed-

Student.cpp

image text in transcribedimage text in transcribedimage text in transcribed-

tifndet DAYOFYETAR H 2 Adefin DAY OR YEAR. II A #include ki ostream b using namespace std 7 class Dayof Yearf public friend bool equal (DayofYear datel DayofYear date2) ;//a friend function that compares two objects yos: it dater is the same as dato2 no: other wi 10 11 DayofYear A default constructor 1/1/2009 Day ofYear (int new day int new month, int new year) 12 void output const int get day return the value of "day int get month. int get year i 16 void set Day of Year (int new day, int new month, int new year) new day-- day, new more Un- month, new year year 17 void set day (int new day day-- new day 18 void set month (int new month 19 20 void set year (int new year) 21 private int day; 23 int month; int char 24 int year; 25 26 27 28 L #endif 29 tifndet DAYOFYETAR H 2 Adefin DAY OR YEAR. II A #include ki ostream b using namespace std 7 class Dayof Yearf public friend bool equal (DayofYear datel DayofYear date2) ;//a friend function that compares two objects yos: it dater is the same as dato2 no: other wi 10 11 DayofYear A default constructor 1/1/2009 Day ofYear (int new day int new month, int new year) 12 void output const int get day return the value of "day int get month. int get year i 16 void set Day of Year (int new day, int new month, int new year) new day-- day, new more Un- month, new year year 17 void set day (int new day day-- new day 18 void set month (int new month 19 20 void set year (int new year) 21 private int day; 23 int month; int char 24 int year; 25 26 27 28 L #endif 29

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions