Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void deleteBook(bookType bookData[]) {
- system("cls");
- if (bookData[0].getBookCount() == 0) {
- cout << "There are no books in the database." << endl;
- system("pause");
- } else {
- bool exit = false;
- bool foundUpper = false;
- char deleteChoice;
- int index;
- do {
- system("cls");
- cout << "****************************************************************"
- "***********************\n";
- cout << "*\t\t\t\t Serendipity Booksellers Delete Book\t\t *\n";
- cout << "*\t\t\t\t\t\t\t\t\t\t *\n";
- cout << "*\t\t\t\t DATABASE SIZE: " << DBSIZE
- << " CURRENT BOOK COUNT: " << bookData[0].getBookCount() << "\t *\n";
- cout << "*\t\t\t\t\t\t\t\t\t\t *\n";
- cout << "****************************************************************"
- "***********************\n";
- index = lookUpBook(bookData);
- if (index >= 0) {
- cout << "Is this the book you want to DELETE? (Y/N): ";
- cin >> deleteChoice;
- while ((deleteChoice != 'Y') && (deleteChoice != 'y') &&
- (deleteChoice != 'N') && (deleteChoice != 'n')) {
- cin.clear();
- cin.ignore(100, '\n');
- cout << "\t\t" << deleteChoice
- << " is not a valid choice. Please enter a valid choice (Y/N): ";
- cin >> deleteChoice;
- }
- if (deleteChoice == 'Y' || deleteChoice == 'y' && index == 19) {
- bookData[index].setAll();
- bookData[index].decBookCount();
- cout << "Book Deleted.\n";
- cout << "Delete Another? <Y/N>: ";
- cin >> deleteChoice;
- while ((deleteChoice != 'Y') && (deleteChoice != 'y') &&
- (deleteChoice != 'N') && (deleteChoice != 'n')) {
- cin.clear();
- cin.ignore(100, '\n');
- cout << "\t\t" << deleteChoice << " is not a valid choice. Please "
- "enter a valid choice (Y/N): ";
- cin >> deleteChoice;
- }
- if (deleteChoice == 'Y' || deleteChoice == 'y' && bookData[0].getBookCount() > 0) {
- system("cls");
- } else if (deleteChoice == 'Y' ||
- deleteChoice == 'y' && bookData[0].getBookCount() <= 0) {
- cout << "There are no more books in the database.\n";
- exit = true;
- system("pause");
- } else
- exit = true;
- }
- else if (deleteChoice == 'Y' || deleteChoice == 'y' && index < 19) {
- bookData[index] = bookData[bookData[index].getBookCount() - 1];
- bookData[bookData[index].getBookCount() - 1].setAll();
- bookData[index].decBookCount();
- cout << "Book Deleted.\n";
- cout << "Delete Another? <Y/N>: ";
- cin >> deleteChoice;
- while ((deleteChoice != 'Y') && (deleteChoice != 'y') &&
- (deleteChoice != 'N') && (deleteChoice != 'n')) {
- cin.clear();
- cin.ignore(100, '\n');
- cout << "\t\t" << deleteChoice << " is not a valid choice. Please "
- "enter a valid choice (Y/N): ";
- cin >> deleteChoice;
- }
- if (deleteChoice == 'Y' || deleteChoice == 'y' && bookData[0].getBookCount() > 0) {
- system("cls");
- } else if (deleteChoice == 'Y' ||
- deleteChoice == 'y' && bookData[0].getBookCount() <= 0) {
- cout << "There are no more books in the database.\n";
- exit = true;
- system("pause");
- } else
- exit = true;
- }
- }
- else
- exit = true;
- } while (exit == false);
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement