Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/etc/Job/Employee.cpp

Go to the documentation of this file.
00001 // Implementation of class Employee
00002 #ifndef __J2K__Employee_CPP__
00003 #define __J2K__Employee_CPP__
00004 
00005 #include <j2k/Fred/Job/Employee.hpp>
00006 
00007 int Employee::count = 0;
00008 int Employee::getCount() { return count; }
00009 
00010 Employee::Employee( const char* first, const char* last )
00011    : birthDate( NULL ), hireDate( NULL )
00012 {
00013    firstName = strdup( first );
00014    lastName  = strdup( last );
00015    ++count;
00016 }
00017 
00018 Employee::Employee( char* first, char* last,
00019                     const Date& birth, const Date& hire )
00020    : birthDate( birth ), hireDate( hire )
00021 {
00022    firstName = strdup( first );
00023    lastName  = strdup( last );
00024    ++count;
00025 }
00026 
00027 Employee::Employee( char* first, char* last,
00028                     UCHAR bday, UCHAR bmonth, USHORT byear,
00029                     UCHAR hday, UCHAR hmonth, USHORT hyear )
00030    : birthDate( new Date( bday, bmonth, byear ) ), 
00031      hireDate(  new Date( hday, hmonth, hyear ) )
00032 {
00033    firstName = strdup( first );
00034    lastName  = strdup( last );
00035    ++count;
00036 }
00037 
00038 Employee::~Employee() {
00039    if ( firstName != NULL )  delete [] firstName;
00040    if ( lastName  != NULL )  delete [] lastName; 
00041    if ( birthDate != NULL )  delete birthDate;
00042    if ( hireDate  != NULL )  delete hireDate; 
00043    --count;
00044 }
00045 
00046 // Client should strdup this, to avoid NULL pointer,
00047 // if Employee gets deleted.
00048 const char* Employee::getFirstName() const {
00049    return firstName;
00050 }
00051 
00052 const char* Employee::getLastName() const {
00053    return lastName;
00054 }
00055 
00056 void Employee::printName() const {
00057    cout << firstName << ' ' << lastName;
00058 }
00059 
00060 void Employee::printInfo() const {
00061    cout << lastName << ", " << firstName;
00062 
00063    if ( hireDate != NULL ) 
00064      cout << "\nHired: " << hireDate;
00065 
00066    if ( birthDate != NULL ) 
00067      cout << "\nBirth date: " << birthDate;
00068 
00069    cout << '\n';
00070 }
00071 
00072 #endif

Generated on Sun Oct 14 18:46:31 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001