MovieList Flashcards

1
Q

MovieList();

A

MovieList::MovieList(): head(NULL){}

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

~MovieList();

A

MovieList::~MovieList(){
Node* currNode = head;
Node* nextNode = NULL;

while(currNode!=NULL){
    nextNode = currNode->next;
    delete currNode;
    currNode = nextNode;
} }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

void addFront(Movie*);

A

void MovieList::addFront(Movie* m){
Node* currNode = new Node();
currNode->data = m;
currNode->next = head;
head = currNode;
}

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

void addBack(Movie*);

A

void MovieList::addBack(Movie* m){
Node* currNode = new Node();
Node *last = head;
currNode->data = m;
currNode->next = NULL;

if (head == NULL){ 
    head = currNode; 
    return; 
} 

while (last->next != NULL){
    last = last->next; 
}

last->next = currNode; 
return;  }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

bool MovieList::get(const string& title, Movie** m) const{
Node * currNode;
currNode = head;

while (currNode!=NULL){
    if (currNode->data->getTitle() == title){
       break; 
    }
    currNode = currNode->next;
}

if (currNode == NULL){
    *m = NULL;
    return false;
}

*m = currNode->data;
return true; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

bool MovieList::remove(const string& title, Movie ** m){
Node * currNode;
Node * prevNode;
currNode = head;
prevNode = NULL;

while (currNode!=NULL){
    if (currNode->data->getTitle() == title){
       break; 
    }
    prevNode = currNode;
    currNode = currNode->next;
}

if (currNode == NULL){
    *m = NULL;
    return false;
}

if (prevNode == NULL){
    head = currNode->next;
}else{
    prevNode->next = currNode->next;
}

*m = currNode->data;
delete currNode;  
return true;   }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

void getFamilyMovies(MovieList& fam) const;

A

void MovieList::getFamilyMovies(MovieList& fam) const{
Node * currNode;
currNode = head;

while (currNode!=NULL){
    if (currNode->data->isfamilyMovie()){
       fam.addBack(currNode->data);
    }
    currNode = currNode->next;
}  }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

void clear();

A

void MovieList::clear(){
Node* currNode = head;
Node* nextNode = NULL;

while(currNode!=NULL){
    nextNode = currNode->next;
    delete currNode->data;
    delete currNode;
    currNode = nextNode;
}
head = NULL; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly