MovieFlix Flashcards
MovieFlix(const string& subscriber);
MovieFlix::MovieFlix(const string& subscriber): subscriber(subscriber), movies(Array<Movie*>()){}
MovieFlix(const MovieFlix&);
MovieFlix::MovieFlix(const MovieFlix& mf): subscriber(mf.subscriber), movies(Array<Movie*>()){
movies = Array<Movie*>();
Movie* movie;
for(int i = 0; i < mf.movies.getSize(); ++i){
movie = mf.movies[i];
movies+=(new Movie(movie->getTitle(), movie->getPrice()));
}
}
~MovieFlix();
MovieFlix::~MovieFlix(){
for(int i = 0; i < movies.getSize(); i++){
delete movies[i];
}
}
bool addMovie(const string& title, float price);
bool MovieFlix::addMovie(const string& title, float price){
Movie* m = new Movie(title, price);
if (movies.getSize() == MAX_ARR){
return false;
}
movies+=m;
return true;
}
bool getMovie(const string& title, Movie **) const;
bool MovieFlix::getMovie(const string& title, Movie** movie) const{
for (int i = 0; i < movies.getSize(); i++){
if(movies[i]->getTitle() == title){
*movie = movies[i];
return true;
}
}
return false;
}
bool removeMovie(const string& title, Movie **);
bool MovieFlix::removeMovie(const string& title, \Movie** movie){
for (int i = 0; i < movies.getSize(); i++){
if(movies[i]->getTitle() == title){
*movie = movies[i];
movies-=*movie;
delete *movie;
return true;
}
}
return false;
}
bool getBestDeal(Movie **) const;
bool MovieFlix::getBestDeal(Movie** movie) const{
if (movies.getSize() == 0) return false;
Movie *deal = movies[0];
for (int i = 1; i < movies.getSize(); i++){ if (movies[i]->getPrice() < deal->getPrice()){ deal = movies[i]; } } *movie = deal; return true; }
void getFamilyMovies(Array<Movie*>& family) const;
void MovieFlix::getFamilyMovies(Array<Movie*>& family) const{
for(int i = 0; i < movies.getSize(); i++){
if(movies[i]->isfamilyMovie()){
family+=movies[i];
}
}
}