bool DatabaseManager::deleteMoviesPath(PathForMovies moviesPath) { QList<Movie> l_movieList = getMoviesByPath(moviesPath); foreach (Movie l_movie, l_movieList) { if (!deleteMovie(l_movie)) { return false; } } QSqlQuery l_query(m_db); l_query.prepare("DELETE FROM path_list WHERE movies_path LIKE :movies_path||'%'"); l_query.bindValue(":movies_path", moviesPath.path()); if(!l_query.exec()) { Macaw::DEBUG("In removeMoviesPath(), deleting path:"); Macaw::DEBUG(l_query.lastError().text()); return false; } return true; }
/** * A little submenu to get the name of the movie to remove, then calls the * deleteMovie function with the required parameters * @param list The list to delete an item from */ void menuDeleteMovie(MovieNodeType **list) { printf("Enter the name of the movie to remove:\n"); char title[MAX_STR]; fgets(title, MAX_STR, stdin); title[strlen(title) - 1] = '\0'; deleteMovie(list, title); }
/* bool MovieTree::deleteMovie(std::string) Description: Deletes a movie from the tree. Example: MovieTree tree; tree.deleteMovie("Back to the Future"); Precondition: The ends of the tree are nil. Movies are organized in the red-black tree correctly. Postcondition: Memory used by the movie is freed. The tree is rearranged as necessary. Returns true if the movie is found. */ bool MovieTree::deleteMovie(std::string title) { Movie *m = searchTree(root, title); if (m != nil) { deleteMovie(m); return true; } else { return false; } }
void HashTable::rentMovie(std::string title) { int rentMovie_Counter = 0; MovieNode *node = root; while (node != NULL) { if ((node-> title).compare(title) > 0) { node = node-> leftChild; } else if ((node-> title).compare(title) < 0) { node = node-> rightChild; } else { if (node-> quantity > 0) { node-> quantity = (node-> quantity) - 1; std::cout << "Movie has been rented." << std::endl; std::cout << "Movie Info:" << std::endl; std::cout << "===========" << std::endl; std::cout << "Ranking:" << node-> ranking << std::endl; std::cout << "Title:" << node-> title << std::endl; std::cout << "Year:" << node-> year << std::endl; std::cout << "Quantity:" << node-> quantity << std::endl; rentMovie_Counter++; if (node-> quantity == 0) { deleteMovie(node-> title); } break; } else { std::cout << "Movie out of stock." << std::endl; rentMovie_Counter++; break; } } } if (rentMovie_Counter == 0) { std::cout << "Movie not found." << std::endl; } }
MovieTree::~MovieTree() { deleteMovie(root); }