//***************************************************************************** // TITLE: Contributor Class // FILENAME: Contributor.cpp // PREPARED FOR: CS 230 Lab 1 // PROGRAMMER: Jerry Gill // DEVELOPMENT DATE: 22 July 08 // COMPILER USED: Visual Studio 2005 // TARGET PLATFORM: Win XP //============================================================================= // PROJECT FILES // LIST ALL PROGRAM AND HEADER FILES IN THE PROJECT // Contributor Class.h Contributor Class.cpp Contributor Main.cpp // Test.cpp // //============================================================================= // REVISION HISTORY // List revision made to the progman // DATE PROGRAMMER DESCRIPTION OF CHANGES MADE // 22 July 08 Jerry Gill Original program // //============================================================================= // Class Description: A class of contributors for future use in the course // // INPUTS: Inputs are currently interactive in the ostream function, but in the // next release, interactivity will be removed. // // OUTPUTS: Outputs are currently sent to the screen //============================================================================= // CONSTANT DEFINITIONS // //============================================================================= // EXTERNAL CLASS VARIABLES // //============================================================================= // START CLASS MEMBER FUNCTION CODE //***************************************************************************** #include "Contributor Class.h" //other necessary includes are in the header Contributor::Contributor() //default constructor { Donation=0.0; Sex=none; IDKey=0; } Contributor::Contributor (std::string Name, double Donation, gender Sex, int IDKey) //overloaded constructor { this->Name=Name; this->Donation=Donation; this->Sex=Sex; this->IDKey=IDKey; } Contributor::Contributor (const Contributor& CCContributor) //copy constructor { Name=CCContributor.Name; Donation=CCContributor.Donation; Sex=CCContributor.Sex; IDKey=CCContributor.IDKey; } ostream& operator << (ostream& out, const Contributor& InContributor) //interactive input { out << "The Contributor's information is: " << endl << endl; out << " Name: " << InContributor.Name << endl; out << " Donation: " << InContributor.Donation << endl; out << " Sex: "; switch (InContributor.Sex) { case male: out << " Male "; break; case female: out << " Female "; break; default: out << " No information available "; } out << endl; out << " IDKey: " << InContributor.IDKey << endl << endl; return out; } istream& operator >> (istream& in, Contributor& InContributor) //output to screen { int sel=0; in.clear(); in.ignore(in.rdbuf()->in_avail(),'\n'); //cout << "Please enter the name of the contributor: "<< endl << endl; //getline (in, InContributor.Name); //cout << endl; //cout << "Please enter the amount of the donation from the contributor: "<< endl << endl; //in >> InContributor.Donation; //cout << endl; //cout << "Please enter number of the sex of the contributor: "<< endl << endl; //cout << "0 = Not Disclosed " << endl; //cout << "1 = The Contributor is male " << endl; //cout << "2 = The Contributor is female "<> sel; //switch (sel) //{ // case 1: InContributor.Sex = male; break; // case 2: InContributor.Sex = female; break; // default: InContributor.Sex = none; break; //} //cout << endl; //cout << "Please enter the ID Key of the contributor: "<< endl << endl; //in >> InContributor.IDKey; //cout << endl << endl; return in; } Contributor& Contributor::operator = (const Contributor& rhs) //overload assignment operator { if (&rhs != this) { this->Name=rhs.Name; this->Donation=rhs.Donation; this->Sex=rhs.Sex; this->IDKey=rhs.IDKey; } return *this; } bool Contributor::operator < (const Contributor& rhs)const //overload < operator { if (Name < rhs.Name) return true; else return false; } bool Contributor::operator > (const Contributor& rhs)const //overload > operator { if (Name > rhs.Name) return true; else return false; } bool Contributor::operator == (const Contributor& rhs)const //overload equality operator { if ((Name==rhs.Name) && (Donation == rhs.Donation) && (Sex == rhs.Sex) && (IDKey == rhs.IDKey)) return true; else return false; } bool Contributor::operator != (const Contributor& rhs)const //overload inequality operator { return ! (*this == rhs); } Contributor::~Contributor() { //for test// cout << "Killing Contributor" <