MovieFlix Flashcards

1
Q

MovieFlix(const string& subscriber);

A

MovieFlix::MovieFlix(const string& subscriber): subscriber(subscriber), movies(Array<Movie*>()){}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

MovieFlix(const MovieFlix&);

A

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()));
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

~MovieFlix();

A

MovieFlix::~MovieFlix(){
for(int i = 0; i < movies.getSize(); i++){
delete movies[i];
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

bool addMovie(const string& title, float price);

A

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;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

bool getMovie(const string& title, Movie **) const;

A

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;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

bool removeMovie(const string& title, Movie **);

A

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;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

bool getBestDeal(Movie **) const;

A

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;        }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

void getFamilyMovies(Array<Movie*>& family) const;

A

void MovieFlix::getFamilyMovies(Array<Movie*>& family) const{
for(int i = 0; i < movies.getSize(); i++){
if(movies[i]->isfamilyMovie()){
family+=movies[i];
}
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly