Advertisement
Guest User

MPlease Kulang

a guest
Jun 25th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <fstream>
  5. #include <algorithm>
  6. #include <opencv2/opencv.hpp>
  7. #include<deque>
  8. #include "MPleaseHeader.h"
  9. using namespace std;
  10. using namespace cv;
  11.  
  12. MovieList::MovieList()//insert new movie
  13. {
  14. ifstream infile;
  15. mnodehead = NULL;
  16. Movie *pre;
  17. pre = new Movie[MovieLineCount(infile)];
  18. MovieInfile(infile, pre);
  19. }
  20.  
  21. int MovieList::MovieIDGenerator()//generates movie ID automatically
  22. {
  23. int max;//holds value of highest vidID and return it after incrementing it by 1
  24. MovieNode *nodePtr;
  25. if (!mnodehead)
  26. {
  27. cout << "Movie list is empty." << endl;
  28. system("pause");
  29. }
  30. else
  31. {
  32. nodePtr = mnodehead;
  33. while (nodePtr)
  34. {
  35. if (nodePtr->next != NULL)
  36. {
  37. nodePtr = nodePtr->next;
  38. }
  39. else
  40. {
  41. max = nodePtr->movies.vidID;
  42. return max + 1;
  43. }
  44. }
  45. }
  46. }
  47.  
  48. void MovieList::MovieInfile(ifstream &infile, Movie movloader[])
  49. {
  50. Movie movholder;//temporary holder of the movies struct retrieved in the text file
  51. int counter = 0;//iterator for the index of the loader struct array
  52. infile.open("movies2img.txt");
  53. if (infile.fail())
  54. {
  55. cout << "Error! Movie text file has not yet been created." << endl;
  56. system("pause");
  57. return;
  58. }
  59. else
  60. {
  61. while (!infile.eof())
  62. {
  63. infile >> movholder.vidID;
  64. infile.ignore();
  65. getline(infile, movholder.title);
  66. getline(infile, movholder.genre);
  67. getline(infile, movholder.production);
  68. infile >> movholder.copies;
  69. infile.ignore();
  70. getline(infile, movholder.filename);
  71. movloader[counter] = movholder;
  72. counter+= 1;
  73. }
  74. for (int i = 0; i < counter; i++)
  75. {
  76. InsertNewMovie(movloader[i]);
  77. }
  78. }
  79. infile.close();
  80. return;
  81. }
  82.  
  83. int MovieList::MovieLineCount(ifstream &infile)//counts the number of lines in the movie text file and returns it after dividing it by six for determining the size of the array
  84. {
  85. string holder;//so the while loop will work
  86. int count = 0;//counts the lines in the text file
  87. infile.open("movies2img.txt");
  88. if (infile.fail())
  89. {
  90. cout << "Error! Movie text file has not yet been created." << endl;
  91. system("pause");
  92. return 0;
  93. }
  94. else
  95. {
  96. while (getline(infile, holder))
  97. {
  98. count++;
  99. }
  100. }
  101. infile.close();
  102. system("pause");
  103. return (count / 6);//count is divided by 6 because there are 6 members inside each node of movies;
  104. }
  105.  
  106. void MovieList::RentMovie(int vidID)//subtracts the number of copies of one movie rented by the user
  107. {
  108. MovieNode *previousNode, *nodePtr;
  109. int found = 0;
  110. if (!mnodehead)
  111. {
  112. cout << "Movie List is empty" << endl;
  113. return;
  114. }
  115.  
  116. if (mnodehead->movies.vidID == vidID)
  117. {
  118. if (Availability(mnodehead->movies.vidID))
  119. {
  120. cout << "Movie has been succesfully rented! " << endl;
  121. mnodehead->movies.copies = mnodehead->movies.copies - 1;
  122. found = 1;
  123. }
  124. else if (!Availability(mnodehead->movies.vidID))
  125. {
  126. cout << "Movie is not available." << endl;
  127. }
  128.  
  129. }
  130. else
  131. {
  132. nodePtr = mnodehead;
  133. previousNode = NULL;
  134.  
  135. while (nodePtr != NULL && nodePtr->movies.vidID != vidID)
  136. {
  137. previousNode = nodePtr;
  138. nodePtr = nodePtr->next;
  139. }
  140.  
  141. if (nodePtr != NULL)
  142. {
  143. if (Availability(nodePtr->movies.vidID))
  144. {
  145. cout << "Movie has been succesfully rented! " << endl;
  146. nodePtr->movies.copies = nodePtr->movies.copies - 1;
  147. found = 1;
  148. }
  149. else if (!Availability(nodePtr->movies.vidID))
  150. {
  151. cout << "Movie is not available." << endl;
  152. }
  153. found = 1;
  154. }
  155. }
  156.  
  157. if (found == 0)
  158. {
  159. cout << "Movie is not available!" << endl;
  160. }
  161. }
  162.  
  163. void MovieList::PrintMovieList()//Displays all movies
  164. {
  165. MovieNode *nodePtr;
  166. if (mnodehead == NULL)
  167. {
  168. cout << "Movie list is empty" << endl;
  169. }
  170. else
  171. {
  172. nodePtr = mnodehead;
  173. while (nodePtr)
  174. {
  175. cout << "Movie Code :" << nodePtr->movies.vidID << endl;
  176. cout << "Title :" << nodePtr->movies.title << endl;
  177. cout << "Genre :" << nodePtr->movies.genre << endl;
  178. cout << "Production :" << nodePtr->movies.production << endl;
  179. cout << "# of Copies :" << nodePtr->movies.copies << endl;
  180. cout << "Image Filename :" << nodePtr->movies.filename << endl;
  181. cout << "*********************" << endl;
  182. cout << endl;
  183. nodePtr = nodePtr->next;
  184. }
  185. }
  186. }
  187.  
  188. void MovieList::InsertNewMovie(Movie movie)//Inserts a new movie node
  189. {
  190. MovieNode *newNode, *nodePtr, *previousNode;
  191. newNode = new MovieNode;
  192. newNode->movies.vidID = movie.vidID;
  193. newNode->movies.title = movie.title;
  194. newNode->movies.genre = movie.genre;
  195. newNode->movies.production = movie.production;
  196. newNode->movies.filename = movie.filename;
  197. newNode->movies.copies = movie.copies;
  198. newNode->next = NULL;
  199.  
  200. if (!mnodehead)
  201. {
  202. mnodehead = newNode;
  203. newNode->next = NULL;
  204. }
  205. else
  206. {
  207. nodePtr = mnodehead;
  208. previousNode = NULL;
  209.  
  210. while (nodePtr != NULL && nodePtr->movies.vidID < movie.vidID)
  211. {
  212. previousNode = nodePtr;
  213. nodePtr = nodePtr->next;
  214. }
  215.  
  216. if (previousNode == NULL)
  217. {
  218. mnodehead = newNode;
  219. newNode->next = nodePtr;
  220. }
  221. else
  222. {
  223. previousNode->next = newNode;
  224. newNode->next = nodePtr;
  225. }
  226. }
  227.  
  228. }
  229.  
  230. void MovieList::ReturnMovie(int vidID)//returns a movie, adding the 1 to its number of copies
  231. {
  232. MovieNode *nodePtr;
  233.  
  234. if (mnodehead->movies.vidID == vidID)
  235. {
  236. ShowMovieDetails(vidID);
  237. mnodehead->movies.copies += 1;
  238. }
  239. else
  240. {
  241. nodePtr = mnodehead;
  242. while (nodePtr != NULL && nodePtr->movies.vidID != vidID)
  243. {
  244. nodePtr = nodePtr->next;
  245. }
  246. if (nodePtr != NULL)
  247. {
  248. nodePtr->movies.copies += 1;
  249. }
  250. else
  251. {
  252. cout << "Movie unavailable.";
  253. }
  254. }
  255. cout << "\nMovie has been successfully returned!" << endl;
  256.  
  257. }
  258.  
  259. void MovieList::ShowMovieDetails(int vidID)//displays the details of the movie along with its movie poster
  260. {
  261. Mat image;
  262. MovieNode *nodePtr;
  263. int found = 0;
  264.  
  265. if (!mnodehead)
  266. {
  267. cout << "There are no movies available." << endl;
  268. return;
  269. }
  270. if (mnodehead->movies.vidID == vidID)//checks if first movie in the list is the movie
  271. {
  272. nodePtr = mnodehead;
  273. cout << "Movie Title: " << nodePtr->movies.title;
  274. cout << "\nMovie Genre: " << nodePtr->movies.genre;
  275. cout << "\nMovie Production: " << nodePtr->movies.production;
  276. cout << "\nMovie Number of Copies: " << nodePtr->movies.copies;
  277. cout << "\nImage Filename: " << nodePtr->movies.filename;
  278. image = imread(nodePtr->movies.filename + ".jpg");
  279. if (image.empty())//if the image does not exist, a message will instead be displayed
  280. {
  281. cout << "\nImage does not exist.";
  282. }
  283. else//else, if the image does exist, the image will be displayed
  284. {
  285. imshow("Movie Poster", image);
  286. }
  287. waitKey(0);
  288. found = 1;
  289. }
  290. else//goes through the rest of thie list if the movie is not found
  291. {
  292. nodePtr = mnodehead;
  293.  
  294. while (nodePtr != NULL && nodePtr->movies.vidID != vidID)
  295. {
  296.  
  297. nodePtr = nodePtr->next;
  298. }
  299. if (nodePtr != NULL)
  300. {
  301. cout << "Movie Title: " << nodePtr->movies.title;
  302. cout << "\nMovie Genre: " << nodePtr->movies.genre;
  303. cout << "\nMovie Production: " << nodePtr->movies.production;
  304. cout << "\nMovie Number of Copies: " << nodePtr->movies.copies;
  305. cout << "\nImage Filename: " << nodePtr->movies.filename;
  306. image = imread(nodePtr->movies.filename + ".jpg");
  307. if (image.empty())
  308. {
  309. cout << "\nImage does not exist.";
  310. }
  311. else
  312. {
  313. imshow("Movie Poster", image);
  314. }
  315.  
  316.  
  317. waitKey(0);
  318. found = 1;
  319. }
  320. }
  321. if (found == 0)
  322. {
  323. cout << "Movie does not exist." << endl;
  324. }
  325.  
  326. }
  327.  
  328. void MovieList::CheckAvailability(int vidID)//calls the availability function to determine whether a movie is available or not
  329. {
  330. MovieNode *nodePtr, *previousNode;
  331. int found = 0;
  332.  
  333.  
  334. if (!mnodehead)
  335. {
  336. cout << "There are no movies available." << endl;
  337. return;
  338. }
  339. if (mnodehead->movies.vidID == vidID)
  340. {
  341. nodePtr = mnodehead;
  342. cout << "Movie Title: " << nodePtr->movies.title;
  343. cout << "\nMovie Genre: " << nodePtr->movies.genre;
  344. cout << "\nMovie Production: " << nodePtr->movies.production;
  345. cout << "\nMovie Number of Copies: " << nodePtr->movies.copies;
  346. cout << "\nImage Filename: " << nodePtr->movies.filename;
  347. if (Availability(vidID))
  348. {
  349. cout << "\nAvailability: Available" << endl;
  350. }
  351. else
  352. {
  353. cout << "\nAvailability: Unavailable" << endl;
  354. }
  355. found = 1;
  356. }
  357. else
  358. {
  359. nodePtr = mnodehead;
  360. previousNode = NULL;
  361.  
  362. while (nodePtr != NULL && nodePtr->movies.vidID != vidID)
  363. {
  364. previousNode = nodePtr;
  365. nodePtr = nodePtr->next;
  366. }
  367. if (nodePtr != NULL)
  368. {
  369. cout << "\nMovie Code: " << nodePtr->movies.vidID;
  370. cout << "\nMovie Title: " << nodePtr->movies.title;
  371. cout << "\nMovie Genre: " << nodePtr->movies.genre;
  372. cout << "\nMovie Production: " << nodePtr->movies.production;
  373. cout << "\nMovie Number of Copies: " << nodePtr->movies.copies;
  374. cout << "\nImage Filename: " << nodePtr->movies.filename;
  375. if (Availability(vidID))
  376. {
  377. cout << "\nAvailability: Available" << endl;
  378. }
  379. else
  380. {
  381. cout << "\nAvailability: Unavailable" << endl;
  382. }
  383. found = 1;
  384. }
  385. }
  386. if (found == 0)
  387. {
  388. cout << "Movie does not exist." << endl;
  389. }
  390.  
  391. }
  392.  
  393. bool MovieList::Availability(int vidID)//returns a bool value, if copies < 1 then the movie is unavailable
  394. {
  395. MovieNode *nodePtr, *previousNode;
  396. bool availability;
  397. int found = 0;
  398.  
  399. if (!mnodehead)
  400. {
  401. cout << "There are no movies available." << endl;
  402. return false;
  403. }
  404. if (mnodehead->movies.vidID == vidID)
  405. {
  406. nodePtr = mnodehead;
  407. if (mnodehead->movies.copies > 0)
  408. {
  409. availability = true;
  410. }
  411. else
  412. {
  413. availability = false;
  414. }
  415. found = 1;
  416. }
  417. else
  418. {
  419. nodePtr = mnodehead;
  420. previousNode = NULL;
  421.  
  422. while (nodePtr != NULL && nodePtr->movies.vidID != vidID)
  423. {
  424. previousNode = nodePtr;
  425. nodePtr = nodePtr->next;
  426. }
  427. if (nodePtr != NULL)
  428. {
  429. // original code: previousNode->next = nodePtr;
  430. if (nodePtr->movies.copies > 0)
  431. {
  432. availability = true;
  433. }
  434. else
  435. {
  436. availability = false;
  437. }
  438. found = 1;
  439. }
  440. }
  441. if (found == 0)
  442. {
  443. cout << "Movie does not exist." << endl;
  444. }
  445. return availability;
  446. }
  447.  
  448. MovieList::~MovieList()
  449. {
  450. MovieNode *nodePtr, *nextNode;
  451. ofstream outfile;
  452.  
  453. outfile.open("movies2img.txt");
  454. if (mnodehead == NULL)
  455. {
  456. cout << "Movie list is empty" << endl;
  457. }
  458. else
  459. {
  460. nodePtr = mnodehead;//nodePtr traverses the list and outputs the contents of each node
  461. while (nodePtr)
  462. {
  463. outfile << nodePtr->movies.vidID << endl;
  464. outfile << nodePtr->movies.title << endl;
  465. outfile << nodePtr->movies.genre << endl;
  466. outfile << nodePtr->movies.production << endl;
  467. outfile << nodePtr->movies.copies << endl;
  468.  
  469. if (nodePtr->next == NULL)
  470. {
  471. outfile << nodePtr->movies.filename;
  472. }
  473. else
  474. {
  475. outfile << nodePtr->movies.filename << endl;
  476. }
  477. nodePtr = nodePtr->next;
  478. }
  479. }
  480. outfile.close();
  481. nodePtr = mnodehead;
  482. while (nodePtr != NULL)
  483. {
  484. nextNode = nodePtr->next;
  485. delete nodePtr;
  486. nodePtr = nextNode;
  487. }
  488. cout << "Movie List has been destroyed!" << endl;
  489. }
  490.  
  491. //Customer Codes
  492.  
  493.  
  494. CustomerList::CustomerList()
  495. {
  496. ifstream infile;
  497. cnodehead = NULL;
  498. Customer *pre;
  499. pre = new Customer[CustomerLineCount(infile)];
  500. CustomerInfile(infile, pre);
  501. }
  502.  
  503. int CustomerList::CustomerLineCount(ifstream &infile)//similar logic to movielinecount, will count number of lines in customer text file and return them divided by three which is representative of the contents of each customer struct
  504. {
  505. string temp;//holds the text inside the text file for customers
  506. int count = 0;
  507. infile.open("customers.txt");
  508. if (infile.fail())
  509. {
  510. cout << "Error! Customer text file has not yet been created!" << endl;
  511. system("pause");
  512. return 0;
  513. }
  514. else
  515. {
  516. while (getline(infile, temp))
  517. {
  518. count++;
  519. }
  520. }
  521. infile.close();
  522. return (count / 3);
  523. }
  524.  
  525. void CustomerList::CustomerInfile(ifstream &infile, Customer custloader[])//used for gathering the data from the text file.
  526. {
  527. Customer custholder;
  528.  
  529. infile.open("customers.txt");
  530. if (infile.fail())
  531. {
  532. cout << "Error! Customer text file has not yet been created!" << endl;
  533. system("pause");
  534. return;
  535. }
  536. else
  537. {
  538. int iterator = 0;
  539. while (!infile.eof())
  540. {
  541. infile >> custholder.custID;
  542. infile.ignore();
  543. getline(infile, custholder.name);
  544. getline(infile, custholder.address);
  545. custloader[iterator] = custholder;
  546. iterator += 1;
  547. }
  548. for (int i = 0; i < iterator; i++)
  549. {
  550. addCustomer(custloader[i]);
  551. }
  552. }
  553. infile.close();
  554. }
  555.  
  556. int CustomerList::CustomerIDGenerator()//generates new ID by finding the highest ID in the customerlist and incrementing it by 1 before returning it
  557. {
  558. int max;//holds value of highest custID and return it after incrementing it by 1
  559. CustomerNode *nodePtr;
  560. if (!cnodehead)
  561. {
  562. cout << "Movie list is empty." << endl;
  563. system("pause");
  564. }
  565. else
  566. {
  567. nodePtr = cnodehead;
  568. while (nodePtr)
  569. {
  570. if (nodePtr->next != NULL)
  571. {
  572. nodePtr = nodePtr->next;
  573. }
  574. else
  575. {
  576. max = nodePtr->customers.custID;
  577. return max + 1;
  578. }
  579. }
  580. }
  581. }
  582.  
  583. void CustomerList::addCustomer(Customer customer)//adds the customer
  584. {
  585. CustomerNode *newNode, *nodePtr, *previousNode;
  586. newNode = new CustomerNode;
  587. newNode->customers.custID = customer.custID;//automatically generated
  588. newNode->customers.name = customer.name;
  589. newNode->customers.address = customer.address;
  590. newNode->next = NULL;
  591.  
  592. if (!cnodehead)
  593. {
  594. cnodehead = newNode;
  595. newNode->next = NULL;
  596. }
  597. else
  598. {
  599. nodePtr = cnodehead;
  600. previousNode = NULL;
  601.  
  602. while (nodePtr != NULL && nodePtr->customers.custID < customer.custID)
  603. {
  604. previousNode = nodePtr;
  605. nodePtr = nodePtr->next;
  606. }
  607.  
  608. if (previousNode == NULL)
  609. {
  610. cnodehead = newNode;
  611. newNode->next = nodePtr;
  612. }
  613. else
  614. {
  615. previousNode->next = newNode;
  616. newNode->next = nodePtr;
  617. }
  618. }
  619. }
  620.  
  621. void CustomerList::showCustomer(int ID)//shows the info of each customer
  622. {
  623. CustomerNode *nodePtr, *previousNode;
  624. bool found;
  625. if (!cnodehead)
  626. {
  627. cout << "Customer List empty!" << endl;
  628. }
  629. else if (cnodehead->customers.custID == ID)
  630. {
  631. system("cls");
  632. cout << "Customer ID: " << cnodehead->customers.custID;
  633. cout << "\nCustomer Name: " << cnodehead->customers.name;
  634. cout << "\nCustomer Address: " << cnodehead->customers.address;
  635. found = true;
  636. }
  637. else
  638. {
  639. nodePtr = cnodehead;
  640.  
  641. while (nodePtr != NULL && nodePtr->customers.custID != ID)
  642. {
  643. previousNode = nodePtr;
  644. nodePtr = nodePtr->next;
  645. }
  646. if (nodePtr != NULL)
  647. {
  648. //di pa pantay
  649. system("cls");
  650. cout << "Customer ID: " << nodePtr->customers.custID;
  651. cout << "\nCustomer Name: " << nodePtr->customers.name;
  652. cout << "\nCustomer Address: " << nodePtr->customers.address;
  653. found = true;
  654. }
  655. }
  656. if (found == false)
  657. {
  658. cout << "Customer does not exist." << endl;
  659. }
  660. }
  661.  
  662. void CustomerList::printCustomerList()//displays all customers
  663. {
  664. CustomerNode *nodePtr;
  665. nodePtr = cnodehead;
  666. while (nodePtr != NULL)
  667. {
  668. cout <<"Customer ID :" << nodePtr->customers.custID << endl;
  669. cout << "Customer Name :" << nodePtr->customers.name << endl;
  670. cout << "Customer Address :" << nodePtr->customers.address << endl;
  671. cout << "*********************" << endl;
  672. cout << endl;
  673. nodePtr = nodePtr->next;
  674. }
  675. }
  676.  
  677. CustomerList::~CustomerList()//destructor of the customer list that will store all the nodes into the text file
  678. {
  679. CustomerNode *nodePtr, *nextNode;
  680. ofstream outfile;
  681. outfile.open("customers.txt");
  682. if (cnodehead == NULL)
  683. {
  684. cout << "Customer list is empty" << endl;
  685. }
  686. else
  687. {
  688. nodePtr = cnodehead;
  689. while (nodePtr)
  690. {
  691. outfile << nodePtr->customers.custID << endl;
  692. outfile << nodePtr->customers.name << endl;
  693.  
  694. if (nodePtr->next)
  695. {
  696. outfile << nodePtr->customers.address << endl;
  697. }
  698. else
  699. {
  700. outfile << nodePtr->customers.address;
  701. }
  702. nodePtr = nodePtr->next;
  703. }
  704. }
  705. outfile.close();
  706.  
  707. nodePtr = cnodehead;
  708. while (nodePtr != NULL)
  709. {
  710. nextNode = nodePtr->next;
  711. delete nodePtr;
  712. nodePtr = nextNode;
  713. }
  714. cout << "\nCustomer List has been destroyed!" << endl;
  715. }
  716.  
  717. //Customer Rent Functions
  718.  
  719. CustomerRentedList::CustomerRentedList()
  720. {
  721.  
  722. }
  723.  
  724. CustomerRentedList::~CustomerRentedList()
  725. {
  726. ofstream outfile;
  727. CustomerRent out;
  728. deque<int>IDsholder;
  729. outfile.open("Rented.txt");
  730. if (outfile.fail())
  731. {
  732. cout << "Error! No customer has rented a movie yet." << endl;
  733. }
  734. else
  735. {
  736. while (!Renter.empty())
  737. {
  738. out = Renter.front();
  739. outfile << '#' << out.customerRenting.custID << endl;
  740. outfile << out.customerRenting.name << endl;
  741. outfile << out.customerRenting.address << endl;
  742. IDsholder = out.vidID;
  743. while (!IDsholder.empty())
  744. {
  745. outfile << IDsholder.front() << endl;
  746. IDsholder.pop_front();
  747. }
  748. }
  749. }
  750. outfile.close();
  751. }
  752.  
  753. void CustomerRentedList::RentAVideo(int custID, deque<int> vidIDs)
  754. {
  755. CustomerNode *cnodePtr;
  756. bool found = false;
  757. CustomerRent holder;
  758.  
  759. if (!cnodehead)
  760. {
  761. cout << "Customer List empty!" << endl;
  762. }
  763. else if (cnodehead->customers.custID == custID)
  764. {
  765. holder.customerRenting = cnodehead->customers;
  766. holder.vidID = vidIDs;
  767. found = true;
  768. }
  769. else
  770. {
  771. cnodePtr = cnodehead;
  772.  
  773. while (cnodePtr != NULL && cnodePtr->customers.custID != custID)
  774. {
  775. cnodePtr = cnodePtr->next;
  776. }
  777. if (cnodePtr != NULL)
  778. {
  779. //newNode->Renter.customerRenting = cnodePtr->customers;
  780. holder.customerRenting = cnodePtr->customers;
  781. holder.vidID = vidIDs;
  782. found = true;
  783. }
  784. }
  785. if (found == false)
  786. {
  787. cout << "Customer does not exist." << endl;
  788. return;
  789. }
  790. Renter.push_back(holder);
  791. }
  792.  
  793.  
  794.  
  795. void CustomerRentedList::PrintAllRented(int custID)
  796. {
  797. CustomerRent temp;
  798. int ID;
  799. if (Renter.empty())
  800. {
  801. cout << "Customer Rent List is empty." << endl;
  802. return;
  803. }
  804. temp = Renter.front();
  805. if (temp.customerRenting.custID == custID)
  806. {
  807. showCustomer(custID);
  808. cout << "\n\nList of Videos Rented..." << endl;
  809. while (!temp.vidID.empty())
  810. {
  811. ID = temp.vidID.front();
  812. ShowMovieTitle(ID);
  813. temp.vidID.pop_front();
  814. }
  815. }
  816. }
  817.  
  818. void CustomerRentedList::ShowMovieTitle(int vidID)
  819. {
  820. MovieNode *nodePtr;
  821. int found = 0;
  822.  
  823. if (!mnodehead)
  824. {
  825. cout << "There are no movies available." << endl;
  826. return;
  827. }
  828. if (mnodehead->movies.vidID == vidID)//checks if first movie in the list is the movie
  829. {
  830. nodePtr = mnodehead;
  831. cout << "\nMovie ID: " << vidID;
  832. cout << "\nMovie Title: " << nodePtr->movies.title;
  833. }
  834. else
  835. {
  836. nodePtr = mnodehead;
  837.  
  838. while (nodePtr != NULL && nodePtr->movies.vidID != vidID)
  839. {
  840. nodePtr = nodePtr->next;
  841. }
  842. if (nodePtr != NULL)
  843. {
  844. cout << "\nMovie ID: " << vidID;
  845. cout << "\nMovie Title: " << nodePtr->movies.title;
  846. }
  847. }
  848. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement