#include "LL2.h" #include #include using namespace std; int main(){ LL List; int choice; char temp[35]; char * Name, * File; int Age; while(choice != 0) { cout << "*----------------------------------------*" << endl; cout << "* Menu " << endl; cout << "*----------------------------------------*" << endl; cout << "Enter a choice: \n" << endl; cout << "0. Exit without saving changes\n"; cout << "1. Exit and save changes\n"; cout << "2. Exit and save to a user specified file\n"; cout << "3. Open a list from a user specified file\n"; cout << "4. Insert at front\n"; cout << "5. Insert at end\n"; cout << "6. Delete \n"; cout << "7. Print the list \n"; cout << "8. Reverse the list \n"; cout << "9. Destroy the list \n"; cout << "10. Search the list \n"; cout << "11. Sort the list in descending order\n"; cout << "12. Sort the list in ascending order\n"; cout << "13. Make a copy of the entire list\n"; cin >> choice; switch(choice) { case 0: cout << "Exiting without saving changes...\n"; break; case 1: cout << "Exiting and saving changes...\n"; { char * File2 = "list.txt"; List.SaveList(File2); break; } case 2: cout << "Exiting and saving changes to user specified file...\n"; cin.get(); cout << "Please enter the file you wish to save the list to: \n"; cin.get(temp, 35, '\n'); File = new char[strlen(temp) + 1]; strcpy(File, temp); List.SaveList(File); break; case 3: cout << "Opening a list from a user specified file...\n"; cin.get(); cout << "Please enter the file you wish to open: \n"; cin.get(temp, 35, '\n'); File = new char[strlen(temp) + 1]; strcpy(File, temp); List.OpenFile(File); break; case 4: Name = List.GetName(); Age = List.GetAge(); List.InsertAtFront(Name, Age); break; case 5: Name = List.GetName(); Age = List.GetAge(); List.InsertAtEnd(Name, Age); break; case 6: Name = List.GetName(); Age = List.GetAge(); List.Delete(Name, Age); break; case 7: List.DisplayNodes(); break; case 8: List.ReverseList(); break; case 9: List.DestroyList(); break; case 10: Name = List.GetName(); Age = List.GetAge(); List.Search(Name, Age); break; case 11: List.SortList_Descend(); break; case 12: List.SortList_Ascend(); break; case 13: { LL newList = List; newList.DisplayNodes(); break; } default: cout << "Invalid selection\n"; break; } } return 0; }