In c++, Design a a class name TimedOff. The purpose of the class is to track an
ID: 3823777 • Letter: I
Question
In c++, Design a a class name TimedOff. The purpose of the class is to track an employees sik leave, vacation, and unpaid time off. It should have, as members, the following instances of the NumDays class described: maxSickDays A NumDays object that recors the maximum number of days of sick leave the employee may take. sickTaken A NumDays object that records the number of days of sick leave the employee has already taken. maxVacation a NumDays object that records the maximum number of days of paid vacation that employee may take. vacTaken a NumDays object that records the number of days of paid vacation the employee has already taken. maxUnpaid a NumDays object that records the maxium number of days of unpaid vacation the employee has may take. unpaidTaken A NumDays object that records the number of days of unpaid leave the employee has taken. Additionally, the class should have members for holding the employee's name and identification number.It should have an appropriate constructor and member functions for storing and retrieving data in any of the member objects. input validation: company policy states that an employee may not accumulate more than 240 hours of paid vacation. The class should not allow the maxVacation object to store a value greater than this amount.
Explanation / Answer
#include "NumDays.h"
#include < iostream>
using namespace std;
class TimeOff
{
private:
NumDays maxSickDays, sickTaken, maxVacation, vacTaken, maxUnpaid, unpaidTaken;
char name[100];
int id;
public:
TimeOff(char inname[100], int inid, float inMaxSickDays, float inSickTaken,
float inMaxVacation,
float inVacTaken, float inMaxUnpaid, float inUnpaidTaken)
{
strcpy(name, inname);
if( inid > 0 ) { id = inid; };
maxSickDays.setDays(inMaxSickDays);
sickTaken.setDays(inSickTaken);
if( inMaxVacation > 240 )
{
cout << "Vacation maxed at 240 hours." << endl;
maxVacation.setDays(240);
}
else { maxVacation.setDays(inMaxVacation); }
vacTaken.setDays(inVacTaken);
maxUnpaid.setDays(inMaxUnpaid);
unpaidTaken.setDays(inUnpaidTaken);
};
TimeOff()
{
name[0] = '';
id = 0;
};
int getEmpNum() { return(id); };
char *getName() { return(name); };
float getMaxSick() { return(maxSickDays.getDays()); };
float getMaxVacation() { return(maxVacation.getDays()); };
float getMaxUnpaid() { return(maxUnpaid.getDays()); };
float getSickTaken() { return(sickTaken.getDays()); };
float getVacationTaken() { return(vacTaken.getDays()); };
float getUnpaidTaken() { return(unpaidTaken.getDays()); };
void setUnpaidTaken(int indays) {
unpaidTaken.addDays(indays);
maxUnpaid.subDays(indays);
};
void setVacTaken(int indays)
{
vacTaken.addDays(indays);
maxVacation.subDays(indays);
};
void setSickTaken(int indays)
{
sickTaken.addDays(indays);
maxSickDays.subDays(indays);
};
};
#endif
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.