/**************************************************************************************** * KYU BAE * 212-04-5868 * * MemberList.CPP * Definitons of member.cpp * *****************************************************************************************/ #include "Member.h" #include #include #include #include #include #include // global constants: //error code const int ErrorState=1; const int ErrorDate=2; const int ErrorJoinCode=4; const int ErrorContestNum=8; const int ErrorAmountPaid=16; const int ErrorCategory=32; const int ErrorCodeNum=64; const long int maylow=19990530; const long int junehigh=19990631; const long int julyhigh=19990732; const long int numlow=50000; const long int numhigh=99999; const float amountlow=0.00; const float amounthigh=99.99; const long int codenumlow=100000; const long int codenumhigh=999999; const int MaxMember=25; const int STRG_SZ=4; /*************************************************************************************** * Constructor * Initialize the data member to zero. ****************************************************************************************/ ClubMember::ClubMember() { SetSurname ("00000"); SetFirstName ('0'); SetState ("00"); SetDate (00000000); SetJoinCode ('0'); SetContestNum(00000); SetAmountPaid(00.00); SetCategory ('0'); SetCodeNum (000000); SetArtist ("000000000"); SetTitle ("000000000"); } /**************************************************************************************** * Set function * Set the values of my data members * they returns nothing *****************************************************************************************/ void ClubMember::SetSurname(char SurnameIn[]) { strcpy(Surname,SurnameIn); } void ClubMember::SetFirstName(char FirstNameIn) { FirstName=FirstNameIn; } void ClubMember::SetState(char StateIn[]) { strcpy(State,StateIn); } void ClubMember::SetDate(long int DateIn) { Date=DateIn; } void ClubMember::SetJoinCode(char JoinCodeIn) { JoinCode=JoinCodeIn; } void ClubMember::SetContestNum(long int ContestNumIn) { ContestNum=ContestNumIn; } void ClubMember::SetAmountPaid(float AmountPaidIn) { AmountPaid=AmountPaidIn; } void ClubMember::SetCategory(char CategoryIn) { Category=CategoryIn; } void ClubMember::SetCodeNum(long int CodeNumIn) { CodeNum=CodeNumIn; } void ClubMember::SetArtist(char ArtistIn[]) { strcpy(Artist,ArtistIn); } void ClubMember::SetTitle(char TitleIn[]) { strcpy(Title,TitleIn); } /**************************************************************************************** * Get functions * These returns the values of data members *****************************************************************************************/ char* ClubMember::GetSurname( void) { return Surname; } char ClubMember::GetFirstName( void) { return FirstName; } char* ClubMember::GetState(void) { return State; } long int ClubMember::GetDate(void) { return Date; } char ClubMember::GetJoinCode(void) { return JoinCode; } long int ClubMember::GetContestNum(void) { return ContestNum; } float ClubMember::GetAmountPaid(void) { return AmountPaid; } char ClubMember::GetCategory(void) { return Category; } long int ClubMember::GetCodeNum(void) { return CodeNum; } char* ClubMember::GetArtist(void) { return Artist; } char* ClubMember::GetTitle(void) { return Title; } /*************************************************************************************** * A FUNCTION: Menu() * CLASS: Employee_List * PURPOSE: Tell user options and return valid choice and for prompting user * RETURNS: User choice (int). ***************************************************************************************/ int MemberList::Menu() const { int i; char text_str[STRG_SZ]; cout <<"\n\n\n Here is your Menu ==> " << endl; cout <<" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl; cout <<" 0 - Quit" << endl; cout <<" 1 - Enter New Data" << endl; if (ListSize) { cout <<" 2 - Display All Records Entered " << endl; cout <<" 3 - Display All Invalid Records" << endl; cout <<" 4 - Display All Valid Records" << endl; cout <<" 5 - Display Summary of Records Entered" << endl; cout <<" 6 - Display Valid Records by Category" << endl; cout <<" 7 - Display Summary of The Bills" << endl; cout <<" 8 - Display Contest Winners " << endl; cout << endl; cout <<" 9 - DIsplay Everything" <= 0) && (i <= 9); } else { Valid_choice = (i >= 0) && (i <= 1); } } while(!Valid_choice); return i; } /*************************************************************************************** * A FUNCTION: Menutwo() * CLASS: Employee_List * PURPOSE: Tell user options and return valid choice and fro reading from the file * RETURNS: User choice (int). ***************************************************************************************/ int MemberList::MenuTwo() const { int i; char text_str[STRG_SZ]; cout <<"\n\n\n Here is your Menu ==> " << endl; cout <<" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl; cout <<" 0 - Quit" << endl; cout <<" 1 - Read Records From The File" << endl; if (ListSize) { cout <<" 2 - Display All Records Entered " << endl; cout <<" 3 - Display All Invalid Records" << endl; cout <<" 4 - Display All Valid Records" << endl; cout <<" 5 - Display Summary of Records Entered" << endl; cout <<" 6 - Display Valid Records by Category" << endl; cout <<" 7 - Display Summary of The Bills" << endl; cout <<" 8 - Display Contest Winners " << endl; cout << endl; cout <<" 9 - DIsplay Everything" <= 0) && (i <= 9); } else { Valid_choice = (i >= 0) && (i <= 1); } } while(!Valid_choice); return i; } /**************************************************************************************** * File IO Function * Purpose: Read records from a file name entered from command line * Class: MemberList * ****************************************************************************************/ void MemberList::FileInput(char * fname) { ListSize = 0; MaxSize = MaxMember; ListPtr = new ClubMember[MaxSize]; ifstream EntryFile(fname,ios::in,ios::nocreate); if (!EntryFile) { cerr << "File could not be opened!!!"<> * Class Clubmember * Overload ">>" * returns : istream& ***************************************************************************************/ istream& operator>> (istream& input, ClubMember& MemberRef) { cout << " Enter Last Name => "; input.getline(MemberRef.Surname, 80); if(!(MemberRef.Surname[0] =='\0')) { cout << " First Name Initial => "; input.get(MemberRef.FirstName); cout << " State => "; input.get(); input.getline(MemberRef.State,80); cout << " Date (YYYYMMDD) => "; input>>MemberRef.Date; cout << " JoinCode (Y/N) => "; input>>MemberRef.JoinCode; cout << " Amount Paid => $ "; input>>MemberRef.AmountPaid; cout << " Category (P, A, B, p, a, or b, etc.)=> "; input>>MemberRef.Category; cout << " CodeNum => "; input>>MemberRef.CodeNum; cout << " Artist => "; input.get(); input.getline(MemberRef.Artist,80); cout << " Title => "; input.getline(MemberRef.Title,80); } else strcpy (MemberRef.Surname, "NONE" ); return input; } /**************************************************************************************** * O FUNCTION: << * CLASS: Club Member * PURPOSE: Overload "<<" operator. * RETURNS: ostream& ******************************************************************************************/ ostream& operator<< (ostream& output, const ClubMember& MemberRef) { output << setprecision(2) << setiosflags(ios::showpoint |ios::fixed) << setw(11) <> ListPtr[ListSize]; if (ListPtr[ListSize].Compare_Name("NONE")) { ListPtr[ListSize].SetContestNum(_contestnum+i); i++; ListSize++; } if (ListSize <= MaxSize) { cout << "\nDo you want to enter more names ?\n "; cin.getline(answer, STRG_SZ); } else { cout << "The list is full.\n"; answer[0] = 'n'; } } while (answer[0] != 'n'); ofstream outFile; outFile.open("cdfile.dat",ios::out); if(!outFile) { cerr<<"File could not be opened" <maylow)&&(_date!=junehigh)&&(_date=numlow)&&(_contnum<=numhigh))) { totalerror+=ErrorContestNum; } float _paid= ListPtr[c].GetAmountPaid(); if (!((_paid>=amountlow)&&(_paid<=amounthigh))) { totalerror+=ErrorAmountPaid; } char _cat=ListPtr[c].GetCategory(); if (!((_cat=='P')||(_cat=='A')||(_cat=='H')||(_cat=='J')||(_cat=='B')||(_cat=='D') ||(_cat=='W')||(_cat=='L')||(_cat=='G')||(_cat=='R')||(_cat=='C')|| (_cat=='p')||(_cat=='a')||(_cat=='h')||(_cat=='j')||(_cat=='b')||(_cat=='d') ||(_cat=='w')||(_cat=='l')||(_cat=='g')||(_cat=='r')||(_cat=='c'))) { totalerror+=ErrorCategory; } long int _code= ListPtr[c].GetCodeNum(); if(!((_code>=codenumlow)&&(_code<=codenumhigh))) { totalerror+=ErrorCodeNum; } Errorcode[c]=totalerror; } } } /***************************************************************************************** * Print functions: This function calls all outputs When called in dispaly function * Prints all records * Return: All Records entered *****************************************************************************************/ void MemberList::PrintAllRecord(MemberList & Storage) { char junk; cout <<"*********************" << endl; cout <<"* Records Entered: *" << endl; cout <<"*********************" << endl; cout <<"_____________________________________________________________________________" << endl; cout.precision(2); cout.setf(ios::showpoint | ios::fixed); cout < "; junk = cin.get(); cout <<"_____________________________________________________________________________" << endl; cout.precision(2); cout.setf(ios::showpoint | ios::fixed); cout < " << endl; cout << endl; junk = cin.get(); } /**************************************************************************************** * Print function:Prints all the invalid records and tell you what error they are * * Returns : INVALID OUTPUT ****************************************************************************************/ void MemberList::PrintInvalid(MemberList & Storage) { char junk; cout <<"**********************"<" << endl; cout << endl; junk = cin.get(); } } } /************************************************************************************************ * Bringerror function: checks total errors and print what error they are * uses bit << * Returns error code * ************************************************************************************************/ void MemberList::BringErrorCode(int totalerror) { int t=1; for (; t<=127 ;t = t << 1) { if (totalerror & t) { if (t==1) { cout <<" ***** Invalid State *****" <"; junk = cin.get(); cout <<"_____________________________________________________________________________" << endl; cout.precision(2); cout.setf(ios::showpoint | ios::fixed ); cout <"; junk = cin.get(); } /*************************************************************************************** * Print function: prints records by the category * Returns: OUTPUT LISTED BY CATEGORY ****************************************************************************************/ void MemberList::PrintCategory(MemberList & Storage) { char junk; cout <<"**************************" << endl; cout <<"* Records By Category: *" << endl; cout <<"**************************" << endl << endl; cout <<"_____________________________________________________________________________" << endl; cout.precision(2); cout.setf(ios::showpoint | ios::fixed); cout <***********************************" << endl; cout << endl; if(ListSize) { for(int i=0;i \n"; junk = cin.get(); cout <<"************************************************************" << endl; cout << endl; if(ListSize) { for(int i=0;i \n"; junk = cin.get(); cout <<"***********************************************************" << endl; cout << endl; if(ListSize) { for(int i=0;i \n"; junk = cin.get(); cout <<"******************************************************************" << endl; cout << endl; if(ListSize) { for(int i=0;i \n"; junk = cin.get(); cout <<"********************************************************" << endl; cout << endl; if(ListSize) { for(int i=0;i \n"; junk = cin.get(); cout <<"***********************************************************" << endl; cout << endl; if(ListSize) { for(int i=0;i \n"; junk = cin.get(); cout <<"*********************************************************" << endl; cout << endl; if(ListSize) { for(int i=0;i \n"; junk = cin.get(); cout <<"***********************************************************" << endl; cout << endl; if(ListSize) { for(int i=0;i \n"; junk = cin.get(); cout <<"*******************************************************************" << endl; cout << endl; if(ListSize) { for(int i=0;i \n"; junk = cin.get(); cout <<"*****************************************************************" << endl; cout << endl; if(ListSize) { for(int i=0;i \n"; junk = cin.get(); cout <<"**************************************************************" << endl; cout << endl; if(ListSize) { for(int i=0;i \n"; junk = cin.get(); } /**************************************************************************************** * Print function: the summary of billings * Returns : Show Billing Summary ****************************************************************************************/ void MemberList::PrintBilling(MemberList & Storage) { char junk; cout <<"**********************" <"; junk = cin.get(); } } } cout<<"\nPress Enter to see next Page =>"; junk = cin.get(); } /**************************************************************************************** * PRint function : checks for winner number and print the winner * Returns: winner contestnumber ****************************************************************************************/ void MemberList::PrintWinner(MemberList & Storage) { char junk; cout << endl; cout <<" ********************" << endl; cout <<" * Contest Winners: *"<"; junk = cin.get(); } /*************************************************************************************** * PRints summary output. * # of records, invalid, valid, billing, by category. * Returns: SUMMARY OUTPUT ***************************************************************************************/ void MemberList::PrintSummary(MemberList & Storage) { char junk; int totalvalid=0; int totalcatP=0; int totalcatB=0; int totalcatD=0; int totalcatW=0; int totalcatR=0; int totalcatC=0; int totalcatL=0; int totalcatJ=0; int totalcatG=0; int totalcatH=0; int totalcatA=0; if(ListSize) { for(int i=0;i " << endl; junk = cin.get(); }