00001 // Implementation of class HourlyWorker 00002 #ifndef __J2K__HourlyWorker_INL__ 00003 #define __J2K__HourlyWorker_INL__ 00004 00005 #include <j2k/Fred/Job/HourlyWorker.hpp> 00006 00007 inline HourlyWorker::HourlyWorker( 00008 const char* first, 00009 const char* last, 00010 double w, 00011 double h 00012 00013 ) : Employee( first, last ), wage( w ), hours( h ) { } 00014 00015 // Set the wage 00016 inline void HourlyWorker::setWage( double w ) { 00017 wage = w; 00018 } 00019 00020 // Set the hours worked 00021 inline void HourlyWorker::setHours( double h ) { 00022 hours = h; 00023 } 00024 00025 // Get the HourlyWorker's pay 00026 inline double HourlyWorker::earnings() const { 00027 if ( hours <= 40 ) { // no overtime 00028 return wage * hours; 00029 } else { // overtime is paid at wage * 1.5 00030 return 40 * wage + ( hours - 40 ) * wage * 1.5; 00031 } 00032 } 00033 00034 // Print the HourlyWorker's name 00035 inline void HourlyWorker::printName() const { 00036 cout << "\n Hourly worker: "; 00037 Employee::print(); 00038 } 00039 00040 // Print the HourlyWorker's name and pay 00041 inline void HourlyWorker::printInfo() const 00042 { 00043 Employee::printName(); 00044 cout << " is an hourly worker with pay of $" 00045 << setiosflags( ios::fixed | ios::showpoint ) 00046 << setprecision( 2 ) << getPay() << endl; 00047 } 00048 00049 #endif