Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. /*
  2. *
  3. *This file fully defines the functions initially stated in MovieManager.h. The main program
  4. *loop function is fully defined below as are other functions necessary for interacting with
  5. *the system.
  6. *
  7. * Author: Nisha Sandhu ID: nishaks
  8. */
  9.  
  10. #include "MovieManager.h"
  11.  
  12. #include <iostream>
  13. using namespace std;
  14.  
  15. //this function is the main program loop that determines what command the user wishes to use
  16. void MovieManager::run(){
  17. numMovies = 0;
  18. bool running = true;
  19.  
  20. while (running){
  21. UI.printMenu();
  22.  
  23. string command;
  24. command = UI.getCommand();
  25.  
  26. if (command == "q" or command == "Q"){
  27. running = false;
  28. }
  29. if (command == "p" or command == "P"){
  30. printInventory();
  31. }
  32. if (command == "AM" or command == "Am" or command == "aM" or command == "am"){
  33. Movie myMovie;
  34. addMovie(myMovie);
  35. }
  36. if (command == "DM" or command == "Dm" or command == "dM" or command == "dm"){
  37. string movieCode;
  38. movieCode = UI.inCode();
  39. discontinueMovie(movieCode);
  40. }
  41. if (command == "RM" or command == "Rm" or command == "rM" or command == "rm"){
  42. string code;
  43. code = UI.inCode();
  44. Renter myRenter;
  45. rentMovie(code, myRenter);
  46. }
  47. if (command == "RR" or command == "Rr" or command == "rR" or command == "rr"){
  48. returnRental();
  49. }
  50. }
  51. }
  52.  
  53. //this function adds a movie object to the movie array of the movie manager
  54. void MovieManager::addMovie(Movie myMovie){
  55. string name;
  56. string code;
  57. code = UI.inCode();
  58. name = UI.inName();
  59. myMovie.setName(name);
  60. myMovie.setCode(code);
  61.  
  62. MovieArray[numMovies] = myMovie;
  63. numMovies = numMovies + 1;
  64. //cout << numMovies << endl;
  65. }
  66.  
  67. //this function discontinues a movie from the movie array by making its fields empty
  68. void MovieManager::discontinueMovie(string movieCode){
  69. for (int i=0; i<20; i++){
  70. if (MovieArray[i].getCode() == movieCode){
  71. MovieArray[i].setCode("");
  72. MovieArray[i].setName("");
  73. numMovies = numMovies - 1;
  74. //cout << numMovies << endl;//TESTING
  75. }
  76. }
  77.  
  78. }
  79.  
  80. //this function
  81. void MovieManager::rentMovie(string code, Renter r){
  82.  
  83. for (int i=0; i<20; i++){
  84. if (MovieArray[i].getCode() == code){
  85. MovieArray[i].rentMovie(r);
  86. }
  87. }
  88. }
  89.  
  90.  
  91. //this function
  92. void MovieManager::returnRental(){
  93.  
  94. }
  95.  
  96. //this function prints the inventory, with movie names/codes, renter names/ids
  97. void MovieManager::printInventory(){
  98. for (int i=0; i<20; i++){
  99. if (not MovieArray[i].getName().empty())
  100. {
  101. cout << "Movie " << i+1 << ": ";
  102. cout << "Name: " << MovieArray[i].getName();
  103. cout << " Code: " << MovieArray[i].getCode() << endl;
  104. }
  105. for (int x = 0; x < 10; x++){
  106. if (not MovieArray[i].getArray(x).getFirst().empty())
  107. {
  108. cout<< "Renter ID: " << MovieArray[i].getArray(x).getID();
  109. cout<< "Renter First Name: " << MovieArray[i].getArray(x).getFirst();
  110. cout<< "Renter Last Name: " << MovieArray[i].getArray(x).getLast();
  111. }
  112. }
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement