Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.45 KB | None | 0 0
  1. #include "serendipity.h"
  2.  
  3. //--------------------------------------------------------//
  4. // File Name: inventoryDatabaseModule.cpp
  5. // Project name: Serendipity Ch 9-11
  6. //--------------------------------------------------------
  7. // Creators name and email: Kevin Nguyen, oggunderscore@gmail.com
  8. // Creation Date: 9/14/19
  9. // Date of Last Modification: 9/14/19
  10. //--------------------------------------------------------//
  11. // Purpose: This class displays the inventoryDatabaseModule.
  12. //--------------------------------------------------------//
  13. // Algorithm:
  14. // Prompt user for an input then execute module functions.
  15. //--------------------------------------------------------//
  16. // Data Dictionary
  17. // Constants
  18. //
  19. // Name Data Type Initial Value
  20. // ---------- -------------- ------------------//
  21. // N/A
  22. //
  23. // Variables
  24. //
  25. // Name Data Type Initial Value
  26. // ---------- -------------- ------------------//
  27. // selection int null
  28. // validInput boolean null
  29. // book array of structs null
  30. // tbook struct null
  31. //--------------------------------------------------------//
  32.  
  33. /*
  34. string book.title[DBSIZE], book.isbn[DBSIZE], book.author[DBSIZE], book.publisher[DBSIZE], book.dateAdded[DBSIZE];
  35. int book.qtyOnHand[DBSIZE], bookCount;
  36. double book.wholesale[DBSIZE], book.retail[DBSIZE];
  37. string tBook.title, tBook.isbn, tBook.author, tBook.publisher, tBook.dateAdded;
  38. int tBook.qtyOnHand;
  39. double tBook.wholesale, tBook.retail;
  40.  
  41. */
  42.  
  43. int bookCount;
  44.  
  45. bookType book[20];
  46.  
  47. bookType tBook;
  48.  
  49. //Setters
  50. void setTitle(bookType book[], string str, int x) {
  51. book[x].title = str;
  52. }
  53. void setISBN(bookType book[], string str, int x) {
  54. book[x].isbn = str;
  55. }
  56. void setAuthor(bookType book[], string str, int x) {
  57. book[x].author = str;
  58. }
  59. void setPub(bookType book[], string str, int x) {
  60. book[x].publisher = str;
  61. }
  62. void setDateAdded(bookType book[], string str, int x) {
  63. book[x].dateAdded = str;
  64. }
  65. void setQty(bookType book[], int amount, int x) {
  66. book[x].qtyOnHand = amount;
  67. }
  68. void setWholesale(bookType book[], double y, int x) {
  69. book[x].wholesale = y;
  70. }
  71. void setRetail(bookType book[], double y, int x) {
  72. book[x].retail = y;
  73. }
  74. int isEmpty(bookType book[], int x) {
  75.  
  76. }
  77.  
  78.  
  79. void resetTemps() {
  80. tBook.title = "EMPTY";
  81. tBook.isbn = "EMPTY";
  82. tBook.author = "EMPTY";
  83. tBook.publisher = "EMPTY";
  84. tBook.dateAdded = getDate() + " (Auto)";
  85. tBook.qtyOnHand = 0;
  86. tBook.wholesale = 0.00;
  87. tBook.retail = 0.00;
  88. }
  89.  
  90. void bookInfo(int bookID) {
  91. cout << "\n\t\t\t\t\tSerendipity Booksellers\n\t\t\t\t\tBook Information\n" << endl;
  92. cout << "Title: " << book[bookID].title << endl;
  93. cout << "ISBN: " << book[bookID].isbn << endl;
  94. cout << "Author: " << book[bookID].author << endl;
  95. cout << "Publisher: " << book[bookID].publisher << endl;
  96. cout << "Date Added: " << book[bookID].dateAdded << endl;
  97. cout << "Quantity-On-Hand: " << book[bookID].qtyOnHand << endl;
  98. cout << "Wholesale Cost: " << book[bookID].wholesale << endl;
  99. cout << "Retail Cost: " << book[bookID].retail << endl;
  100. pause();
  101. clear();
  102. inventoryDatabaseModule();
  103. }
  104. size_t findCaseInsensitive(string data, string toSearch, size_t pos) {
  105. // Convert complete given String to lower case
  106. transform(data.begin(), data.end(), data.begin(), ::tolower);
  107. // Convert complete given Sub String to lower case
  108. transform(toSearch.begin(), toSearch.end(), toSearch.begin(), ::tolower);
  109. // Find sub string in given string
  110. return data.find(toSearch, pos);
  111. }
  112.  
  113. void lookUpBook() {
  114. clear();
  115. cout << "\t\tSerendipity Booksellers\n\t\tInventory Database\n\n\t\t1. Look up a Book\n\t\t2. Add a Book\n\t\t3. Edit a Book's Record\n\t\t4. Delete a Book\n\t\t5. Return to Main Menu\n\n\t\tPlease type in your input: 1\n";
  116. string search;
  117. cout << "\nSearch: ";
  118. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  119. getline(cin, search);
  120. bool validInput;
  121. char selection;
  122. for (int x = 0; x < DBSIZE; x++) {
  123. size_t found = findCaseInsensitive(book[x].title, search, 0);
  124. if (found != string::npos) {
  125. do {
  126. if (validInput != true) {
  127. cout << "\"" << book[x].title << "\" found by Title. Would you like to view it? (Y/N): ";
  128. cin >> selection;
  129. switch (selection) {
  130. case 'Y':
  131. case 'y':
  132. validInput = true;
  133. clear();
  134. bookInfo(x);
  135. case 'N':
  136. case 'n':
  137. validInput = true;
  138. inventoryDatabaseModule();
  139. //found = findCaseInsensitive(book[x].title, search, found+1);
  140. break;
  141. default:
  142. cout << "Please enter a valid response! ";
  143. validInput = false;
  144. break;
  145. }
  146. } else {
  147. break;
  148. }
  149. } while (found != string::npos);
  150. } else {
  151. do {
  152. if (validInput != true) {
  153. found = book[x].isbn.find(search);
  154. if (found != string::npos) {
  155. do {
  156. if (validInput != true) {
  157. cout << "\"" << book[x].isbn << "\" found by ISBN. Would you like to view it? (Y/N): ";
  158. cin >> selection;
  159. switch (selection) {
  160. case 'Y':
  161. case 'y':
  162. validInput = true;
  163. clear();
  164. bookInfo(x);
  165. case 'N':
  166. case 'n':
  167. validInput = true;
  168. inventoryDatabaseModule();
  169. //found = findCaseInsensitive(book[x].title, search, found+1);
  170. break;
  171. default:
  172. cout << "Please enter a valid response! ";
  173. validInput = false;
  174. break;
  175. }
  176. } else {
  177. break;
  178. }
  179. } while (found!= string::npos);
  180. } else {
  181. if (x == 19) {
  182. do {
  183. if (validInput != true) {
  184. cout << "Error: Could not find Title / ISBN. Try again? (Y/N): ";
  185. cin >> selection;
  186. switch (selection) {
  187. case 'Y':
  188. case 'y':
  189. validInput = true;
  190. clear();
  191. lookUpBook();
  192. case 'N':
  193. case 'n':
  194. validInput = true;
  195. inventoryDatabaseModule();
  196. //found = findCaseInsensitive(book[x].title, search, found+1);
  197. break;
  198. default:
  199. cout << "Please enter a valid response! ";
  200. validInput = false;
  201. break;
  202. }
  203. } else {
  204. break;
  205. }
  206. } while (found != string::npos);
  207. }
  208. }
  209. } else {
  210. break;
  211. }
  212. } while (found != string::npos);
  213. }
  214. }
  215. inventoryDatabaseModule();
  216. }
  217. void editor(int x);
  218.  
  219. void addBook() {
  220. clear();
  221. if (bookCount >= DBSIZE) {
  222. cout << "Database is full! Please delete some books to proceed! (" << bookCount << "/" << DBSIZE << ")\n";
  223. pause();
  224. clear();
  225. inventoryDatabaseModule();
  226. } else {
  227. bool validInput;
  228. char selection;
  229. do {
  230. cout << fixed;
  231. cout.precision(2);
  232. cout << "*************************************************************\n\t\tSerendipity Booksellers\n\t\t\tAdd Book Menu\n\n\tCurrent Database Size: " << bookCount << "/" << DBSIZE << "\n" << endl;
  233. cout << "\t\t\t\t\t+ Pending Values +" << endl;
  234. cout << "(1) Enter Book Title\t\t\t > --" << tBook.title << endl;
  235. cout << "(2) Enter ISBN\t\t\t\t > --" << tBook.isbn << endl;
  236. cout << "(3) Enter Author\t\t\t > --" << tBook.author << endl;
  237. cout << "(4) Enter Publisher\t\t\t > --" << tBook.publisher << endl;
  238. cout << "(5) Enter Date Added\t\t\t > --" << tBook.dateAdded << endl;
  239. cout << "(6) Enter Quantity on Hand\t\t > --" << tBook.qtyOnHand << endl;
  240. cout << "(7) Enter Wholesale Cost\t\t > --$" << tBook.wholesale << endl;
  241. cout << "(8) Enter Retail Price\t\t\t > --$" << tBook.retail << endl;
  242. cout << "(9) Save Book to Database\t" << endl;
  243. cout << "(0) Return to Inventory Menu" << endl;
  244. cout << "\n*************************************************************\n\tChoice (0-9): ";
  245. cin >> selection;
  246. validInput = true;
  247. switch(selection) {
  248. case '1':
  249. validInput = true;
  250. clear();
  251. cout << "*************************************************************\n\tInput Book Title: ";
  252. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  253. getline(cin, tBook.title);
  254. addBook();
  255. break;
  256. case '2':
  257. validInput = true;
  258. clear();
  259. cout << "*************************************************************\n\tInput ISBN: ";
  260. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  261. getline(cin, tBook.isbn);
  262. addBook();
  263. break;
  264. case '3':
  265. validInput = true;
  266. clear();
  267. cout << "*************************************************************\n\tInput Author: ";
  268. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  269. getline(cin, tBook.author);
  270. addBook();
  271. break;
  272. case '4':
  273. validInput = true;
  274. clear();
  275. cout << "*************************************************************\n\tInput Publisher: ";
  276. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  277. getline(cin, tBook.publisher);
  278. addBook();
  279. break;
  280. case '5':
  281. validInput = true;
  282. clear();
  283. cout << "*************************************************************\n\tInput Date: ";
  284. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  285. getline(cin, tBook.dateAdded);
  286. addBook();
  287. break;
  288. case '6':
  289. validInput = true;
  290. clear();
  291. cout << "*************************************************************\n\tInput Quantity on Hand: ";
  292. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  293. cin >> tBook.qtyOnHand;
  294. addBook();
  295. break;
  296. case '7':
  297. validInput = true;
  298. clear();
  299. cout << "*************************************************************\n\tInput Wholesale Cost: ";
  300. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  301. cin >> tBook.wholesale;
  302. addBook();
  303. break;
  304. case '8':
  305. validInput = true;
  306. clear();
  307. cout << "*************************************************************\n\tInput Retail Price: ";
  308. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  309. cin >> tBook.retail;
  310. addBook();
  311. break;
  312. case '9':
  313. validInput = true;
  314. clear();
  315. //SAVING CODE
  316. setTitle(book, tBook.title, bookCount);
  317. setISBN(book, tBook.isbn, bookCount);
  318. setAuthor(book, tBook.author, bookCount);
  319. setPub(book, tBook.publisher, bookCount);
  320. setDateAdded(book, tBook.dateAdded, bookCount);
  321. setQty(book, tBook.qtyOnHand, bookCount);
  322. setWholesale(book, tBook.wholesale, bookCount);
  323. setRetail(book, tBook.retail, bookCount);
  324.  
  325.  
  326. bookCount++;
  327. cout << "Save was successful. Database: (" << bookCount << "/" << DBSIZE << ")";
  328. cout << endl;
  329. resetTemps();
  330. clear();
  331. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  332. addBook();
  333. break;
  334. case '0':
  335. validInput = true;
  336. clear();
  337. resetTemps();
  338. inventoryDatabaseModule();
  339. break;
  340. default:
  341. validInput = false;
  342. clear();
  343. cout << "\nPlease enter a valid selection!\n";
  344. break;
  345. }
  346. } while (validInput == false);
  347. }
  348. clear();
  349. }
  350.  
  351. void editBook() {
  352. clear();
  353. cout << "\t\tSerendipity Booksellers\n\t\tInventory Database\n\n\t\t1. Look up a Book\n\t\t2. Add a Book\n\t\t3. Edit a Book's Record\n\t\t4. Delete a Book\n\t\t5. Return to Main Menu\n\n\t\tPlease type in your input: 3\n";
  354. string search;
  355. cout << "\nSearch: ";
  356. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  357. getline(cin, search);
  358. cout << "\n";
  359. bool validInput;
  360. char selection;
  361. for (int x = 0; x < DBSIZE; x++) {
  362. size_t found = book[x].title.find(search);
  363. if (found != string::npos) {
  364. do {
  365. if (validInput != true) {
  366. cout << "\"" << book[x].title << "\" found by Title. Would you like to edit it? (Y/N): ";
  367. cin >> selection;
  368. switch (selection) {
  369. case 'Y':
  370. case 'y':
  371. validInput = true;
  372. clear();
  373. tBook.title = book[x].title;
  374. tBook.isbn = book[x].isbn;
  375. tBook.author = book[x].author;
  376. tBook.publisher = book[x].publisher;
  377. tBook.dateAdded = book[x].dateAdded;
  378. tBook.qtyOnHand = book[x].qtyOnHand;
  379. tBook.wholesale = book[x].wholesale;
  380. tBook.retail = book[x].retail;
  381. editor(x);
  382. case 'N':
  383. case 'n':
  384. validInput = true;
  385. clear();
  386. inventoryDatabaseModule();
  387. break;
  388. default:
  389. cout << "Please enter a valid response! ";
  390. validInput = false;
  391. break;
  392. }
  393. } else {
  394. break;
  395. }
  396. } while (validInput != true);
  397. } else {
  398. do {
  399. if (validInput != true) {
  400. found = book[x].isbn.find(search);
  401. if (found != string::npos) {
  402. do {
  403. if (validInput != true) {
  404. cout << "\"" << book[x].isbn << "\" found by ISBN. Would you like to edit it? (Y/N): ";
  405. cin >> selection;
  406. switch (selection) {
  407. case 'Y':
  408. case 'y':
  409. validInput = true;
  410. clear();
  411. tBook.title = book[x].title;
  412. tBook.isbn = book[x].isbn;
  413. tBook.author = book[x].author;
  414. tBook.publisher = book[x].publisher;
  415. tBook.dateAdded = book[x].dateAdded;
  416. tBook.qtyOnHand = book[x].qtyOnHand;
  417. tBook.wholesale = book[x].wholesale;
  418. tBook.retail = book[x].retail;
  419. editor(x);
  420. case 'N':
  421. case 'n':
  422. validInput = true;
  423. clear();
  424. inventoryDatabaseModule();
  425. break;
  426. default:
  427. cout << "Please enter a valid response! ";
  428. validInput = false;
  429. break;
  430. }
  431. } else {
  432. break;
  433. }
  434. } while (validInput != true);
  435. } else {
  436. if (x == 19) {
  437. do {
  438. if (validInput != true) {
  439. cout << "Error: Could not find Title / ISBN. Try again? (Y/N): ";
  440. cin >> selection;
  441. switch (selection) {
  442. case 'Y':
  443. case 'y':
  444. validInput = true;
  445. clear();
  446. editBook();
  447. case 'N':
  448. case 'n':
  449. validInput = true;
  450. clear();
  451. inventoryDatabaseModule();
  452. break;
  453. default:
  454. cout << "Please enter a valid response! ";
  455. validInput = false;
  456. break;
  457. }
  458. } else {
  459. break;
  460. }
  461. } while (validInput != true);
  462. }
  463. }
  464. } else {
  465. break;
  466. }
  467. } while (validInput != true);
  468. }
  469. }
  470. //former clear
  471. }
  472.  
  473. void removeBook(int x);
  474.  
  475. void deleteBook() {
  476.  
  477. clear();
  478. cout << "\t\tSerendipity Booksellers\n\t\tInventory Database\n\n\t\t1. Look up a Book\n\t\t2. Add a Book\n\t\t3. Edit a Book's Record\n\t\t4. Delete a Book\n\t\t5. Return to Main Menu\n\n\t\tPlease type in your input: 4\n";
  479. string search;
  480. cout << "\nSearch: ";
  481. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  482. getline(cin, search);
  483. cout << "\n";
  484. bool validInput;
  485. char selection;
  486. for (int x = 0; x < DBSIZE; x++) {
  487. size_t found = book[x].title.find(search);
  488. if (found != string::npos) {
  489. do {
  490. if (validInput != true) {
  491. cout << "\"" << book[x].title << "\" found by Title. Would you like to delete it? (Y/N): ";
  492. cin >> selection;
  493. switch (selection) {
  494. case 'Y':
  495. case 'y':
  496. validInput = true;
  497. clear();
  498. removeBook(x);
  499. case 'N':
  500. case 'n':
  501. validInput = true;
  502. clear();
  503. inventoryDatabaseModule();
  504. break;
  505. default:
  506. cout << "Please enter a valid response! ";
  507. validInput = false;
  508. break;
  509. }
  510. } else {
  511. break;
  512. }
  513. } while (validInput != true);
  514. } else {
  515. do {
  516. if (validInput != true) {
  517. found = book[x].isbn.find(search);
  518. if (found != string::npos) {
  519. do {
  520. if (validInput != true) {
  521. cout << "\"" << book[x].isbn << "\" found by ISBN. Would you like to delete it? (Y/N): ";
  522. cin >> selection;
  523. switch (selection) {
  524. case 'Y':
  525. case 'y':
  526. validInput = true;
  527. clear();
  528. removeBook(x);
  529. case 'N':
  530. case 'n':
  531. validInput = true;
  532. clear();
  533. inventoryDatabaseModule();
  534. break;
  535. default:
  536. cout << "Please enter a valid response! ";
  537. validInput = false;
  538. break;
  539. }
  540. } else {
  541. break;
  542. }
  543. } while (validInput != true);
  544. } else {
  545. if (x == 19) {
  546. do {
  547. if (validInput != true) {
  548. cout << "Error: Could not find Title / ISBN. Try again? (Y/N): ";
  549. cin >> selection;
  550. switch (selection) {
  551. case 'Y':
  552. case 'y':
  553. validInput = true;
  554. clear();
  555. deleteBook();
  556. case 'N':
  557. case 'n':
  558. validInput = true;
  559. clear();
  560. inventoryDatabaseModule();
  561. break;
  562. default:
  563. cout << "Please enter a valid response! ";
  564. validInput = false;
  565. break;
  566. }
  567. } else {
  568. break;
  569. }
  570. } while (validInput != true);
  571. }
  572. }
  573. } else {
  574. break;
  575. }
  576. } while (validInput != true);
  577. }
  578. }
  579. }
  580.  
  581. void printDatabase() {
  582. clear();
  583. cout << "\t----------- Database Table -----------\n" << endl;
  584. cout << "ID\tTitle\t\t\tISBN\t\tAuthor\t\tPublisher\tDate\tQty\tWholesale\tRetail\n-----------------------------------------" << endl;
  585. for (int x = 0; x < bookCount; x++) {
  586. cout << x << "\t" << book[x].title << "\t\t\t" << book[x].isbn << "\t\t" << book[x].author << "\t\t" << book[x].publisher << "\t" << book[x].dateAdded << "\t" << book[x].qtyOnHand << "\t" << book[x].wholesale << "\t" << book[x].retail << endl;
  587. }
  588. cout << endl;
  589. pause();
  590. inventoryDatabaseModule();
  591. }
  592.  
  593. void inventoryDatabaseModule() {
  594. char selection;
  595. bool validInput;
  596. resetTemps();
  597. clear();
  598. if (getExitCode() != true) {
  599. do {
  600. cout << "\t\tSerendipity Booksellers\n\t\tInventory Database\n\n\t\t1. Look up a Book\n\t\t2. Add a Book\n\t\t3. Edit a Book's Record\n\t\t4. Delete a Book\n\t\t5. Return to Main Menu\n\n\t\tPlease type in your input: ";
  601. cin >> selection;
  602. validInput = true;
  603. switch(selection) {
  604. case '1':
  605. validInput = true;
  606. lookUpBook();
  607. break;
  608. case '2':
  609. validInput = true;
  610. addBook();
  611. break;
  612. case '3':
  613. validInput = true;
  614. editBook();
  615. break;
  616. case '4':
  617. validInput = true;
  618. deleteBook();
  619. break;
  620. case '5':
  621. validInput = true;
  622. mainMenu();
  623. break;
  624. case '6':
  625. validInput = true;
  626. printDatabase();
  627. break;
  628. default:
  629. validInput = false;
  630. clear();
  631. cout << "\nPlease enter a valid selection!\n";
  632. break;
  633. }
  634.  
  635. } while (validInput == false);
  636. }
  637. }
  638.  
  639. void removeBook(int x) {
  640. clear();
  641. int finalBook = x;
  642. cout << "Book \"" << book[x].title << "\" has been deleted." << endl;
  643. for (int y = x; y < DBSIZE-1; y++){
  644. book[y].title = book[y+1].title;
  645. book[y].isbn = book[y+1].isbn;
  646. book[y].author = book[y+1].author;
  647. book[y].publisher = book[y+1].publisher;
  648. book[y].dateAdded = book[y+1].dateAdded;
  649. book[y].qtyOnHand = book[y+1].qtyOnHand;
  650. book[y].wholesale = book[y+1].wholesale;
  651. book[y].retail = book[y+1].retail;
  652. finalBook++;
  653. }
  654. finalBook++;
  655. book[finalBook].title = "";
  656. book[finalBook].isbn = "";
  657. bookCount--;
  658. cout << "Database: (" << bookCount << "/" << DBSIZE << ")" << endl;
  659. cout << endl;
  660. pause();
  661. inventoryDatabaseModule();
  662. }
  663.  
  664. void editor(int x) {
  665. clear();
  666. bool validInput;
  667. char selection;
  668.  
  669. do {
  670. cout << fixed;
  671. cout.precision(2);
  672. cout << "*************************************************************\n\t\tSerendipity Booksellers\n\t\t\tBook Editor Menu\n\n\tCurrent Database Size: " << bookCount << "/" << DBSIZE << "\n" << endl;
  673. cout << "\t\t\t\t\t+ Pending Values +" << endl;
  674. cout << "(1) Enter Book Title\t\t\t > --" << tBook.title << endl;
  675. cout << "(2) Enter ISBN\t\t\t\t > --" << tBook.isbn << endl;
  676. cout << "(3) Enter Author\t\t\t > --" << tBook.author << endl;
  677. cout << "(4) Enter Publisher\t\t\t > --" << tBook.publisher << endl;
  678. cout << "(5) Enter Date Added\t\t\t > --" << tBook.dateAdded << endl;
  679. cout << "(6) Enter Quantity on Hand\t\t > --" << tBook.qtyOnHand << endl;
  680. cout << "(7) Enter Wholesale Cost\t\t > --$" << tBook.wholesale << endl;
  681. cout << "(8) Enter Retail Price\t\t\t > --$" << tBook.retail << endl;
  682. cout << "(9) Save Book to Database\t" << endl;
  683. cout << "(0) Return to Inventory Menu" << endl;
  684. cout << "\n*************************************************************\n\tChoice (0-9): ";
  685. cin >> selection;
  686. validInput = true;
  687. switch(selection) {
  688. case '1':
  689. validInput = true;
  690. clear();
  691. cout << "*************************************************************\n\tInput Book Title: ";
  692. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  693. getline(cin, tBook.title);
  694. editor(x);
  695. break;
  696. case '2':
  697. validInput = true;
  698. clear();
  699. cout << "*************************************************************\n\tInput ISBN: ";
  700. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  701. getline(cin, tBook.isbn);
  702. editor(x);
  703. break;
  704. case '3':
  705. validInput = true;
  706. clear();
  707. cout << "*************************************************************\n\tInput Author: ";
  708. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  709. getline(cin, tBook.author);
  710. editor(x);
  711. break;
  712. case '4':
  713. validInput = true;
  714. clear();
  715. cout << "*************************************************************\n\tInput Publisher: ";
  716. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  717. getline(cin, tBook.publisher);
  718. editor(x);
  719. break;
  720. case '5':
  721. validInput = true;
  722. clear();
  723. cout << "*************************************************************\n\tInput Date: ";
  724. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  725. getline(cin, tBook.dateAdded);
  726. editor(x);
  727. break;
  728. case '6':
  729. validInput = true;
  730. clear();
  731. cout << "*************************************************************\n\tInput Quantity on Hand: ";
  732. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  733. cin >> tBook.qtyOnHand;
  734. editor(x);
  735. break;
  736. case '7':
  737. validInput = true;
  738. clear();
  739. cout << "*************************************************************\n\tInput Wholesale Cost: ";
  740. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  741. cin >> tBook.wholesale;
  742. editor(x);
  743. break;
  744. case '8':
  745. validInput = true;
  746. clear();
  747. cout << "*************************************************************\n\tInput Retail Price: ";
  748. cin.ignore(numeric_limits<streamsize>::max(),'\n'); //Clear input buffer from previous text.
  749. cin >> tBook.retail;
  750. editor(x);
  751. break;
  752. case '9':
  753. validInput = true;
  754. clear();
  755. //SAVING CODE
  756. setTitle(book, tBook.title, bookCount);
  757. setISBN(book, tBook.isbn, bookCount);
  758. setAuthor(book, tBook.author, bookCount);
  759. setPub(book, tBook.publisher, bookCount);
  760. setDateAdded(book, tBook.dateAdded, bookCount);
  761. setQty(book, tBook.qtyOnHand, bookCount);
  762. setWholesale(book, tBook.wholesale, bookCount);
  763. setRetail(book, tBook.retail, bookCount);
  764.  
  765. cout << "Edit was successful. Database: (" << bookCount << "/" << DBSIZE << ")";
  766. cout << endl;
  767. resetTemps();
  768. pause();
  769. clear();
  770. editor(x);
  771. break;
  772. case '0':
  773. validInput = true;
  774. clear();
  775. resetTemps();
  776. inventoryDatabaseModule();
  777. break;
  778. default:
  779. validInput = false;
  780. clear();
  781. cout << "\nPlease enter a valid selection!\n";
  782. break;
  783. }
  784. } while (validInput == false);
  785. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement