Write a class Work whose objects represent working times (in whole minutes)
and salary rates (in whole cents per minute). With this class, the following operation shall
be possible:
Work* w = new Work(25, 60); // 25 cent/min, 60 min
w->add(65); // add 65 minutes working time
w->printSalary(); // prints salary "31,25" (25*125 Cents)
bool okay = w->subtract(60); // attempts to subtract 60 minutes
// returns false, if not sufficient time
// available (time remains unchanged)
Work::reset(*w); // reset working time to zero
Work v(30); // 30 cent/min, 0 min
int r = w.compare(*v); // 0 if salaries of w and v are equal,
// 1, if w’s salary is bigger, -1, else
Work u(v); // u becomes a copy of v
Comments
Leave a comment