////////////////////////////////////////////////////////////////// // // person.cpp // // Started by Jeff Ondich on 4/15/98 // Last modified 4/15/98 // // This is an implementation of a simple class representing // a single person. // ////////////////////////////////////////////////////////////////// #include "person.h" ////////////////////////////////////////////////////////////////// // // Person::Person( const string& name, int year, int month, int day ) // ////////////////////////////////////////////////////////////////// Person::Person( const string& name, int year, int month, int day ) { mName = name; mBirthYear = year; mBirthMonth = month; mBirthDay = day; } ////////////////////////////////////////////////////////////////// // // Person::Person( void ) // ////////////////////////////////////////////////////////////////// Person::Person( void ) { mName = "Elena"; mBirthYear = 1993; mBirthMonth = 10; mBirthDay = 19; } ////////////////////////////////////////////////////////////////// // // Person::SetName( const string& name ) // ////////////////////////////////////////////////////////////////// void Person::SetName( const string& name ) { mName = name; } ////////////////////////////////////////////////////////////////// // // Person::GetName( string& name ) // ////////////////////////////////////////////////////////////////// void Person::GetName( string& name ) { name = mName; } ////////////////////////////////////////////////////////////////// // // Person::Age( int currentYear, int currentMonth, int currentDay ) // // Returns the age of the person, measured as an integral // number of years. // ////////////////////////////////////////////////////////////////// int Person::Age( int currentYear, int currentMonth, int currentDay ) { int age = currentYear - mBirthYear; if( currentMonth < mBirthMonth || (currentMonth == mBirthMonth && currentDay < mBirthDay) ) { age--; } return( age ); }