Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- *This file fully defines the functions initially stated in MovieManager.h. The main program
- *loop function is fully defined below as are other functions necessary for interacting with
- *the system.
- *
- * Author: Nisha Sandhu ID: nishaks
- */
- #include "MovieManager.h"
- #include <iostream>
- using namespace std;
- //this function is the main program loop that determines what command the user wishes to use
- void MovieManager::run(){
- numMovies = 0;
- bool running = true;
- while (running){
- UI.printMenu();
- string command;
- command = UI.getCommand();
- if (command == "q" or command == "Q"){
- running = false;
- }
- if (command == "p" or command == "P"){
- printInventory();
- }
- if (command == "AM" or command == "Am" or command == "aM" or command == "am"){
- Movie myMovie;
- addMovie(myMovie);
- }
- if (command == "DM" or command == "Dm" or command == "dM" or command == "dm"){
- string movieCode;
- movieCode = UI.inCode();
- discontinueMovie(movieCode);
- }
- if (command == "RM" or command == "Rm" or command == "rM" or command == "rm"){
- string code;
- code = UI.inCode();
- Renter myRenter;
- rentMovie(code, myRenter);
- }
- if (command == "RR" or command == "Rr" or command == "rR" or command == "rr"){
- returnRental();
- }
- }
- }
- //this function adds a movie object to the movie array of the movie manager
- void MovieManager::addMovie(Movie myMovie){
- string name;
- string code;
- code = UI.inCode();
- name = UI.inName();
- myMovie.setName(name);
- myMovie.setCode(code);
- MovieArray[numMovies] = myMovie;
- numMovies = numMovies + 1;
- //cout << numMovies << endl;
- }
- //this function discontinues a movie from the movie array by making its fields empty
- void MovieManager::discontinueMovie(string movieCode){
- for (int i=0; i<20; i++){
- if (MovieArray[i].getCode() == movieCode){
- MovieArray[i].setCode("");
- MovieArray[i].setName("");
- numMovies = numMovies - 1;
- //cout << numMovies << endl;//TESTING
- }
- }
- }
- //this function
- void MovieManager::rentMovie(string code, Renter r){
- for (int i=0; i<20; i++){
- if (MovieArray[i].getCode() == code){
- MovieArray[i].rentMovie(r);
- }
- }
- }
- //this function
- void MovieManager::returnRental(){
- }
- //this function prints the inventory, with movie names/codes, renter names/ids
- void MovieManager::printInventory(){
- for (int i=0; i<20; i++){
- if (not MovieArray[i].getName().empty())
- {
- cout << "Movie " << i+1 << ": ";
- cout << "Name: " << MovieArray[i].getName();
- cout << " Code: " << MovieArray[i].getCode() << endl;
- }
- for (int x = 0; x < 10; x++){
- if (not MovieArray[i].getArray(x).getFirst().empty())
- {
- cout<< "Renter ID: " << MovieArray[i].getArray(x).getID();
- cout<< "Renter First Name: " << MovieArray[i].getArray(x).getFirst();
- cout<< "Renter Last Name: " << MovieArray[i].getArray(x).getLast();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement