Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. void deleteBook(bookType bookData[]) {
  2. system("cls");
  3. if (bookData[0].getBookCount() == 0) {
  4. cout << "There are no books in the database." << endl;
  5. system("pause");
  6. } else {
  7. bool exit = false;
  8. bool foundUpper = false;
  9. char deleteChoice;
  10. int index;
  11. do {
  12. system("cls");
  13. cout << "****************************************************************"
  14. "***********************\n";
  15. cout << "*\t\t\t\t Serendipity Booksellers Delete Book\t\t *\n";
  16. cout << "*\t\t\t\t\t\t\t\t\t\t *\n";
  17. cout << "*\t\t\t\t DATABASE SIZE: " << DBSIZE
  18. << " CURRENT BOOK COUNT: " << bookData[0].getBookCount() << "\t *\n";
  19. cout << "*\t\t\t\t\t\t\t\t\t\t *\n";
  20. cout << "****************************************************************"
  21. "***********************\n";
  22. index = lookUpBook(bookData);
  23. if (index >= 0) {
  24. cout << "Is this the book you want to DELETE? (Y/N): ";
  25. cin >> deleteChoice;
  26. while ((deleteChoice != 'Y') && (deleteChoice != 'y') &&
  27. (deleteChoice != 'N') && (deleteChoice != 'n')) {
  28. cin.clear();
  29. cin.ignore(100, '\n');
  30. cout << "\t\t" << deleteChoice
  31. << " is not a valid choice. Please enter a valid choice (Y/N): ";
  32. cin >> deleteChoice;
  33. }
  34. if (deleteChoice == 'Y' || deleteChoice == 'y' && index == 19) {
  35. bookData[index].setAll();
  36. bookData[index].decBookCount();
  37. cout << "Book Deleted.\n";
  38. cout << "Delete Another? <Y/N>: ";
  39. cin >> deleteChoice;
  40. while ((deleteChoice != 'Y') && (deleteChoice != 'y') &&
  41. (deleteChoice != 'N') && (deleteChoice != 'n')) {
  42. cin.clear();
  43. cin.ignore(100, '\n');
  44. cout << "\t\t" << deleteChoice << " is not a valid choice. Please "
  45. "enter a valid choice (Y/N): ";
  46. cin >> deleteChoice;
  47. }
  48. if (deleteChoice == 'Y' || deleteChoice == 'y' && bookData[0].getBookCount() > 0) {
  49. system("cls");
  50. } else if (deleteChoice == 'Y' ||
  51. deleteChoice == 'y' && bookData[0].getBookCount() <= 0) {
  52. cout << "There are no more books in the database.\n";
  53. exit = true;
  54. system("pause");
  55. } else
  56. exit = true;
  57. }
  58.  
  59. else if (deleteChoice == 'Y' || deleteChoice == 'y' && index < 19) {
  60. bookData[index] = bookData[bookData[index].getBookCount() - 1];
  61. bookData[bookData[index].getBookCount() - 1].setAll();
  62. bookData[index].decBookCount();
  63. cout << "Book Deleted.\n";
  64. cout << "Delete Another? <Y/N>: ";
  65. cin >> deleteChoice;
  66. while ((deleteChoice != 'Y') && (deleteChoice != 'y') &&
  67. (deleteChoice != 'N') && (deleteChoice != 'n')) {
  68. cin.clear();
  69. cin.ignore(100, '\n');
  70. cout << "\t\t" << deleteChoice << " is not a valid choice. Please "
  71. "enter a valid choice (Y/N): ";
  72. cin >> deleteChoice;
  73. }
  74. if (deleteChoice == 'Y' || deleteChoice == 'y' && bookData[0].getBookCount() > 0) {
  75. system("cls");
  76. } else if (deleteChoice == 'Y' ||
  77. deleteChoice == 'y' && bookData[0].getBookCount() <= 0) {
  78. cout << "There are no more books in the database.\n";
  79. exit = true;
  80. system("pause");
  81. } else
  82. exit = true;
  83. }
  84. }
  85.  
  86.  
  87. else
  88. exit = true;
  89. } while (exit == false);
  90. }
  91. return;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement