void UI::menu(char ans) { switch(ans) { case 'a': case 'A': addIndividual(); break; case 's': case 'S': searchMenu(); break; case 'p': case 'P': sortMenu(); break; case 'r': case 'R': remove(); break; case 'l': case 'L': cout << "The current size of this list is: " << core.getSizeOfList() << endl; break; case 'q': case 'Q': cout << endl; exit(1); break; default: cout << "Incorrect input, please try again!" << endl; break; } }
void UI::searchMenu() { cout << endl; char choice; cout << "Search by: " << endl; cout << "(N) Name" << endl << "(G) Gender" << endl << "(B) Year of Birth" << endl << "(D) Year of Death" << endl << "(M) Return to Menu" << endl << "(Q) Quit program " << endl; cout << "Select a letter: "; cin >> choice; switch(choice) { case 'n': case 'N': searchName(); //<- breyta í core.searchName þegar core hefur það fall break; case 'g': case 'G': searchGender(); break; case 'b': case 'B': searchBirth(); break; case 'd': case 'D': searchDeath(); break; case 'M': case 'm': return; //this->menu(); break; case 'q': case 'Q': exit(1); break; default: errorInput(); searchMenu(); } searchMenu(); }
void sameDistrict(Data* data){ cout << "Where do you want to check for ads?\n"; string district; getline(cin, district); vector<Advertisement *> ads = data->getAdsInSameDistrict(district); saleOrPurchase(ads,data); SearchMenu searchMenu(data, ads); searchMenu.createMenu(); if(data->getSignedInUser() != NULL) signedInMenu(data); else mainMenu(data); }
void deleteBook() { int index = searchMenu(2); if (index == -1) return;//returns if book doesn't exist printf("Are you sure you want to delete this book?\n Press 1 for yes and 2 for no\n>"); int choice = -1; fflush(stdin); while (choice != 1) { scanf("%d", &choice); switch (choice) { case 1: break; case 2: printf("You have decided not to delete this book\n"); return; default: printf("Your input was not recognised\n"); } fflush(stdin); } int i = index; for (; i < (numBooks - 1); i++) { strcpy((aryptr + i)->title, (aryptr + i + 1)->title);//copies (i+1)th values into i, overwriting it. strcpy((aryptr + i)->author, (aryptr + i + 1)->author); strcpy((aryptr + i)->publisher, (aryptr + i + 1)->publisher); (aryptr + i)->price = (aryptr + i + 1)->price; (aryptr + i)->year = (aryptr + i + 1)->year; strcpy((aryptr + i)->genre, (aryptr + i + 1)->genre); strcpy((aryptr + i)->isbn, (aryptr + i + 1)->isbn); (aryptr + i)->stock = (aryptr + i + 1)->stock; (aryptr + i)->aMatch = 1; } realloc(aryptr, ((numBooks - 1)*sizeof(struct book))); if (aryptr == NULL) { printf("An error occured\n"); return; } numBooks--;//decrements numBooks by 1 to account for the deleted book }
void ui::menuSwitch() { // This swith calls the next menu UI dependant on the user "choice". switch(choice) { case 1 : insertMenu(); break; case 2 : searchMenu(); break; case 3 : printerMenu(); break; case 4 : deleteMenu(); break; default: break; } }
int CEventFinderMenu::showMenu(void) { int res = menu_return::RETURN_REPAINT; *m_event = false; if(*m_search_list == EventList::SEARCH_LIST_CHANNEL) { m_search_channelname = g_Zapit->getChannelName(*m_search_channel_id); } else if(*m_search_list == EventList::SEARCH_LIST_BOUQUET) { m_search_channelname = bouquetList->Bouquets[*m_search_bouquet_id]->channelList->getName(); } else if(*m_search_list == EventList::SEARCH_LIST_ALL) { m_search_channelname ==""; } CStringInputSMS stringInput(LOCALE_EVENTFINDER_KEYWORD, m_search_keyword); CMenuForwarder * mf2 = new CMenuForwarder(LOCALE_EVENTFINDER_KEYWORD, true, *m_search_keyword, &stringInput, NULL, CRCInput::RC_1 ); CMenuOptionChooser * mo0 = new CMenuOptionChooser(LOCALE_EVENTFINDER_SEARCH_WITHIN_LIST, m_search_list, SEARCH_LIST_OPTIONS, SEARCH_LIST_OPTION_COUNT, true, NULL, CRCInput::RC_2); CMenuForwarder * mf1 = new CMenuForwarder("", *m_search_list != EventList::SEARCH_LIST_ALL, m_search_channelname, this, "3", CRCInput::RC_3 ); CMenuOptionChooser * mo1 = new CMenuOptionChooser(LOCALE_EVENTFINDER_SEARCH_WITHIN_EPG, m_search_epg_item, SEARCH_EPG_OPTIONS, SEARCH_EPG_OPTION_COUNT, true, NULL, CRCInput::RC_4); CMenuForwarder * mf0 = new CMenuForwarder(LOCALE_EVENTFINDER_START_SEARCH, true, NULL, this, "1", CRCInput::RC_5 ); CMenuWidget searchMenu(LOCALE_EVENTFINDER_HEAD, NEUTRINO_ICON_FEATURES); searchMenu.addItem(mf2, false); searchMenu.addItem(new CMenuSeparator(CMenuSeparator::LINE)); searchMenu.addItem(mo0, false); searchMenu.addItem(mf1, false); searchMenu.addItem(mo1, false); searchMenu.addItem(new CMenuSeparator(CMenuSeparator::LINE)); searchMenu.addItem(mf0, false); res = searchMenu.exec(NULL, ""); return(res); }
void adminOptions() { int choice = 1; printf("Welcome, administrator.\n"); while (choice != 0) { choice = -1;//resets choice to an impossible value //If not, if they entered an integer and then entered a character later, it would automatically go into the option corresponding to the last integer they entered printf("01\tAdd New Book\n02\tModify Existing Book\n03\tDelete Book\n"); printf("04\tSearch\n00\tLog Out\n\n>"); scanf("%d", &choice); switch (choice) { case 1: addBook(); break; case 2: modifyDetails(); break; case 3: deleteBook(); break; case 4: searchMenu(0); break; case 0: isAdmin = 0; printf("You have successfully logged out.\n"); return; default: printf("Your input was not recognised\n"); } fflush(stdin);//stops the programme going into an infinite loop if user enters a character for choice //This is because if scanf can't deal with an input, it leaves it on the buffer so every time, it would otherwise try and fail to read it in } }
void modifyDetails() { int index = -1; char isbn[14]; int choice = 0; char tempString[70] = "\0"; char blank[3] = ""; index = searchMenu(3); // Once this is finished, this will be called to check and validate the ISBN Code Number. if (index != -1) { printf("The Title is: \"%s\"\nIf you would like to change this press 1, if not, press any other key.\n", (aryptr + index)->title); scanf("%d", &choice); if (choice == 1) { do { printf("Enter the new Title\n"); fflush(stdin); gets(tempString); } while (tempString[0] == NULL); strcpy((aryptr + index)->title, tempString); choice = 0;//resets choice to 0 } printf("The Author is %s\nIf you would like to change this press 1, if not, press any other key.\n", (aryptr + index)->author); scanf("%d", &choice); if (choice == 1) { do { printf("Enter the new Author\n"); fflush(stdin); gets(tempString); } while (tempString[0] == NULL); strcpy((aryptr + index)->author, tempString); choice = 0;//resets choice to 0 } printf("The Publisher is %s\nIf you would like to change this press 1, if not, press any other key.\n", (aryptr + index)->publisher); scanf("%d", &choice); if (choice == 1) { do { printf("Enter the new Publisher\n"); fflush(stdin); gets(tempString); } while (tempString[0] == NULL); strcpy((aryptr + index)->publisher, tempString); choice = 0;//resets choice to 0 } printf("The Price is %f\nIf you would like to change this press 1, if not, press any other key.\n", (aryptr + index)->price); scanf("%d", &choice); if (choice == 1) { do { fflush(stdin); printf("Enter the new Price\n"); scanf("%f", &((aryptr + index)->price)); } while ((aryptr + index)->price < 0); choice = 0;//resets choice to 0 } printf("The Year is %d\nIf you would like to change this press 1, if not, press any other key.\n", (aryptr + index)->year); scanf("%d", &choice); if (choice == 1) { fflush(stdin); printf("Enter the new Year\n"); scanf("%d", &((aryptr + index)->year)); choice = 0;//resets choice to 0 } printf("The Genre is %s\nIf you would like to change this press 1, if not, press any other key.\n", (aryptr + index)->genre); scanf("%d", &choice); if (choice == 1) { do { printf("Enter the new Genre\n"); fflush(stdin); gets(tempString); } while (tempString[0] == NULL); strcpy((aryptr + index)->genre, tempString); choice = 0;//resets choice to 0 } printf("The stock is %d\nIf you would like to change this press 1, if not, press any other key.\n", (aryptr + index)->stock); scanf("%d", &choice); if (choice == 1) { do { fflush(stdin); printf("Enter the new Price\n"); scanf("%f", &((aryptr + index)->price)); } while ((aryptr + index)->stock < 0); choice = 0;//resets choice to 0 } } else if (validateisbn(isbn)) { printf("The isbn is valid but the book doesn't exist in the records\n"); printf("would you like to add it? Press 1 if you do, if not, press any other key\n"); scanf("%d", &choice); if (choice == 1) { //addBook(); choice = 0;//resets choice to 0 } } else { printf("The isbn is not valid. Please make sure you entered it correctly\n"); } }