i need help with chapter 14 program challenge 6 in book starting out with c++ fr
ID: 3718707 • Letter: I
Question
i need help with chapter 14 program challenge 6 in book starting out with c++ from control structures
through objects
Design a class named TimeOff. The purpose of the class is to track an employee’s sick leave, vacation, and unpaid time off. It should have, as members, the following instances of the NumDays class described in Programming Challenge 4: maxSickDays A NumDays object that records 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 the employee may take. vacTaken A NumDays object that records the number of days of paid vacation the employee has already taken. Programming Challenges 885 maxUnpaid A NumDays object that records the maximum number of days of unpaid vacation the employee 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
here is your class : ---------->>>>>>>>>>
#include<iostream>
using namespace std;
class TimeOff{
private:
NumDays maxSickDays;
NumDays sickTaken;
NumDays maxVacation;
NumDays vacTaken;
NumDays maxUnpaid;
NumDays unpaidTaken;
string name;
int id;
public:
TimeOff(string n,int id){
name = n;
this->id = id;
maxSickDays = NumDays(0);
sickTaken = NumDays(0);;
maxVacation = NumDays(0);
vacTaken = NumDays(0);
maxUnpaid = NumDays(0);
unpaidTaken = NumDays(0);
}
TimeOff(string n,int id,NumDays MSD,NumDays ST,NumDays MV,NumDays VT,NumDays MU,NumDays UT){
name = n;
this->id = id;
setMaxSickDays(MSD);
setSickTaken(ST);
setMaxVacation(MV);
setVacationTaken(VT);
setMaxUnpaid(MU);
setUnpaidTaken(UT);
}
void setMaxSickDays(NumDays msd){
maxSickDays = msd;
}
void setSickTaken(NumDays st){
sickTaken = st;
}
void setMaxVacation(NumDays mv){
maxVacation = mv;
}
void setVacationTaken(NumDays vt){
vacTaken = vt;
}
void setMaxUnpaid(NumDays mu){
maxUnpaid = mu;s
}
void setUnpaidTaken(NumDays ut){
unpaidTaken = ut;
}
void setName(string n){
name = n;
}
void setID(int id){
this->id = id;
}
//getter
string getName(){
return name;
}
int getID(){
return id;
}
NumDays getMaxSickDays(){
return maxSickDays;
}
NumDays getSickTaken(){
return sickTaken;
}
NumDays getMaxVacation(){
return maxVacation;
}
NumDays getVacationTaken(){
return vacTaken;
}
NumDays getMaxUnpaid(){
return maxUnpaid;
}
NumDays getUnpaidTaken(){
return unpaidTaken;
}
};
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.