/******************************************************************** * KYU BAE * PROJECT #2 < Cd_main.cpp > * ******************************************************************** * * Objective: * The program provide the opportunity to demonstrate the following * 1) A general ability to write and debug a modest size c++ program. * 2) An understanding of classes and templates * 3) An understanding of pointers and * 4) The implementation of a singly and a doubly linked lists. ********************************************************************* * * This project implement a database to manage a CD club. The program * does this through two linked lists. ths first is a singly linked list * which contains information on each CD.The second list is a doubly * linked list containinf information on each individual club members. ********************************************************************/ // #include #include #include #include #include #include #include "slist.h" #include "Cdinventory.h" #include "Member.h" #include "dlist.h" //Global constants const int MaxMember =25; const int STRG_SZ = 4; void pause (void); /******************************************************************** * instruction() * print out choices * returns nothing ********************************************************************/ void instructions() { cout << "\n\n *** << MENU >> *** \n"; cout << " ***********************************************\n"; cout << " * Enter one of the following: *\n" << " * 1 to insert before the current node *\n" << " * 2 to insert after the current node *\n" << " * *\n" << " * 3 to change the current node *\n" << " * 4 to delete the current node *\n" << " * *\n" << " * 5 to print the current node *\n" << " * 6 to print all records *\n" << " * *\n"; cout << " * 0 to end the process *\n"; cout << " ***********************************************\n"; } /******************************************************************** * template testList() - doubly linked list * test driver for doubly linked list for member * add, delete print the current node and all records * this is where added onto linked list * return nothing ********************************************************************/ // Function to test an Club member template< class T > void testList( List< T > &listObject, const char *type ) { cout << " Working With a List of " << type << " Records\n"; char junk; instructions(); int choice; T value; do { cout << " Select Your Choice ==> "; cin >> choice; switch ( choice ) { case 1: cout << "Enter " << type << ": \n"; cin >> value; listObject.insertAtFront( value ); break; case 2: cout << "Enter " << type << ": \n"; cin >> value; listObject.insertAtBack( value ); break; case 3: listObject.changeCurrent(); break; case 4: if ( listObject.removeCurrent( value ) ) cout <<"\n" << value << "\nAbove Node was removed from list\n\n\n"; cin.ignore(); cout <<"Hit Enter Key to Continue =>\n"; junk=cin.get(); instructions(); break; case 5: listObject.printCurrent(); instructions(); break; case 6: listObject.print(); instructions(); break; } } while ( choice != 0 ); } /******************************************************************** * template testList() - singly linked list * test driver for singly linked list for CD inventory * add, delete print the current node and all records * this is where added onto linked list * return nothing ********************************************************************/ // Function to test an CD inventory template< class _T > void _testList( sList< _T > &_listObject, const char *_type ) { cout << " Working With a List of " << _type << " Records\n"; char junk; instructions(); int choice; _T value; do { cout << " Select Your Choice ==> "; cin >> choice; switch ( choice ) { case 1: cout << "Enter " << _type << ": \n"; cin >> value; _listObject._insertAtFront( value ); break; case 2: cout << "Enter " << _type << ": \n"; cin >> value; _listObject._insertAtBack( value ); break; case 3: _listObject._changeCurrent(); break; case 4: if ( _listObject._removeCurrent( value ) ) cout <<"\n" << value << "\nAbove Node was removed from list\n\n\n"; cin.ignore(); cout <<"Hit Enter Key to Continue =>\n"; junk=cin.get(); instructions(); break; case 5: _listObject._printCurrent(); instructions(); break; case 6: _listObject._print(); instructions(); break; } } while ( choice != 0 ); } /******************************************************************** * main () * dos command line: at dos command line file names are entered * two data file names must be entered * returns interger * ********************************************************************/ int main(int argc, char *argv[]) { int choice; do{ cout <<"\n\n\n\n\n\n\n\n\n\n\n\n\n Do you want to run Proj1 or Proj2? ( 1 or 2)\n"; cout <<" ********************************************\n\n"; cout <<" 1) Project 1\n"; cout <<" 2) Project 2\n\n"; cout <<" 3) Quit\n"; cout <<"\n Select ==> "; cin >>choice; }while (!(choice>0 && choice<4)); if (choice == 1) { cout <<"\n\n\n The Project 1 program is not required to run here!!!\n"; cout <<" Start the Program again for the Proj 2!!\n\n\n"; } else if(choice ==2) { int num; do { do { cout <<"\n\n\n\n\n\n\n\n Which list do you want to work with?(1 or 2)\n"; cout <<" ********************************************\n\n"; cout <<" 1) CD Club Member\n"; cout <<" 2) CD Inventory\n"; cout <<"\n 3) Quit\n"; cout <<"\n Select ==> "; cin >> num; } while (!(num>0 && num<4)); if (num==1) { MemberList TheList; List membLinkList; cout <<"\n\n\n\n << The CD Club Member Link-List >> \n\n"; TheList.FileInput(argv[1]); for (int i=0;i<25;i++) { membLinkList.insertAtBack(TheList.ListPtr[i]); } if (!(num==3)) testList( membLinkList, " CD Club Member" ); } else if (num==2) { Cdlist _TheList; sList CdLinkList; cout <<"\n\n\n << The CD Inventory Link-List >>\n\n"; _TheList._FileInput(argv[2]); for (int i=0;i<37;i++) { CdLinkList._insertAtBack(_TheList._ListPtr[i]); } if (!(num==3)) _testList( CdLinkList, "Cd Inventory" ); } else cout <<"\n\n The program ending!!!\n\n"; }while (!(num==3)); } else cout <<"\n\n The program ending!!!\n\n"; return 0; } /******************************************************************** * * * ********************************************************************/