bool StoreManager::checkIn(int customerId, int movieId) { Customer *customer = findCustomer(customerId); Movie *movie = findMovie(movieId); if (customer == NULL) std::cout << "Customer not found.\n\n"; if (movie == NULL) std::cout << "Movie not found.\n\n"; if (customer == NULL || movie == NULL) return false; std::set<Movie *> movies = customer->getMovies(); for (std::set<Movie *>::iterator it = movies.begin(); it != movies.end(); ++it) { if (*it == movie) { customer->removeMovie(movie); movie->setInCount(movie->getInCount() + 1); movie->setOutCount(movie->getOutCount() - 1); return true; } } std::cout << "That movie was not found in customer's profile.\n\n"; return false; }
bool StoreManager::checkOut(int customerId, int movieId) { Customer *customer = findCustomer(customerId); Movie *movie = findMovie(movieId); if (customer == NULL) std::cout << "Customer not found.\n\n"; if (movie == NULL) std::cout << "Movie not found.\n\n"; if (customer == NULL || movie == NULL) return false; else { if (movie->getOutCount() == movie->getStockCount()) { std::cout << movie->getTitle() << " is out of stock.\n" << "Cannot add to customer # " << customer->getId() << "\n\n"; return false; } else { customer->addMovie(movie); movie->setInCount(movie->getInCount() - 1); movie->setOutCount(movie->getOutCount() + 1); return true; } } }
void FinalProject::printMovieDirector(MovieNode *node){ // before, this function called printMovieInventory instead of printMovieDirector recursively if(node !=NULL){ if(node->leftChild){ printMovieDirector(node->leftChild); } findMovie(node->title); if(node->rightChild){ printMovieDirector(node->rightChild); } } }