I need to implement a \"business class\" from appt.cpp(Use inheritance) that is
ID: 3897612 • Letter: I
Question
I need to implement a "business class" from appt.cpp(Use inheritance) that is used for business appointments, (adding fields for priority, deadline, location, cost, and a pay code). Also add enumeration for the days and types of appointments
/////////////////////////// appt.cpp /////////////// #include "appt.h" appt::appt(int d, int h, string i, bool done) { this->d = d; this->h = h; this->item = i; this->done = done; } appt::~appt() { } void appt::set_day(int d) { this->d = d; } void appt::set_time(int h) { this->h = h; } void appt::set_task(std::string item) { this->item = item; } void appt::set_is_done(bool done) { this->done = done; } int appt::get_day() { return d; } int appt::get_time() { return h; } std::string appt::get_task() { return (std::string) item; } bool appt::get_is_done() { return done; } void appt::clear() { this->d = 0; this->h = 0; this->item = "unset"; this->done = false; } void appt::show_appt() { std::string day[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; cout << "Day : " << day[d] << endl; cout << "Time : " << h << endl; cout << "Task : " << item << endl; cout << (!done ? "Not Finished" : "Finished") << endl; cout << endl; } /////////////////////////// appt.h /////////////// #ifndef APPT_H #define APPT_H #include using namespace std; // This is the appointment class // It should hold all information for the appointment class appt { private: int d, h; string item; bool done; public: appt(int d = 0, int h = 0000, std::string item = "unset", bool done = false); // default constructor ~appt(); // destructor // set the day of the appointment void set_day(int d); // set the time of the appointment void set_time(int h); // set the task of the appointment void set_task(std::string item); // set the status of the appointment void set_is_done(bool done); // return the day of the appointment int get_day(); // return the time of the appointment int get_time(); // return the task of the appointment std::string get_task(); // return the status of the appointment bool get_is_done(); // restores appointment information to default void clear(); // print all the appointment information void show_appt(); }; // end appt class #endif
Explanation / Answer
class businessappt : public appt {
private:
string priority;
int dealine;
string location;
double cost;
strinh paycode;
public:
enum Day {Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday};
enum Appttype { Type1, Type2,Type3 };
businessappt(int d, int h, string i, bool de, string p, int dd, string l, double c, string pc) : appt(d,h,i,de){
priority = p;
deadline = dd;
location = l;
cost = c;
paycode = pc;
}
void set_priority(string a){
priority = a;
}
void set_location(string a){
location = a;
}
void set_deadline(int a){
deadline = a;
}
void set_cost(double a){
cost = p;
}
void set_paycode(string a){
paycode = p;
}
string get_priority(){
return priority;
}
string get_location(){
return location;
}
int get_deadline(){
return deadline;
}
double get_cost(){
return priority;
}
string get_paycode(){
return paycode;
}
void clear(){
appt::clear();
location = "";
priority = "":
deadline = 0;
cost = 0;
paycode = "";
}
void show(){
appt::show();
cout << "Priority:" << priority << endl;
cout << "Location:" << location << endl;
cout << "Deadline:" << deadline << endl;
cout << "Cost:" << cost << endl;
cout << "Paycode:" << paycode << endl;
}
}