• A MovieList is a doubly linked list in which each element of the list is a MovieNode • A MovieNode has the following attributes: o title: a string, the title of the movie o year: an integer for the year the movie was first released o director: a string, the name of the director of the movie o genre: a string, the genre (or category of the movie) e.g. comedy, drama, action o next: a reference to the next MovieNode in the list, or None if it is the last in the list o prev: a reference to the previous MovieNode, or None if it is the first in the list Task : Complete the method remove_movie(self, movie) • Input to the method is a MovieObject • The method removes that MovieObject from the list You are provided with code in __main___ for testing which prompts the user for a number of movies to remove, finds the MovieNode with that title in the MovieList. and removes it For example, if the list contained the following movies, printed using the MovieList method display(): Title: Point Break Title: The Power of the Dog Title: Hunt for the Wilderpeople Title: Jojo Rabbit Title: Promising Young Woman Title: The Piano removing the movies with the following titles: Point Break Jojo Rabbit would result in the following MovieList Title: The Power of the Dog Title: Hunt for the Wilderpeople Title: Promising Young Woman The Piano Title: Year: 1991 Year: 2021 Year: 2016 Year: 2019 Year: 2020 Year: 1993 Year: 2021 Year: 2016 Year: 2020 Year: 1993 Director: Kathryn Bigelow Director: Jane Campion Director: Taika Waititi Director: Taika Waititi Director: Emerald Fennell Director: Jane Campion Director: Jane Campion Director: Taika Waititi Director: Emerald Fennell Director: Jane Campion Genre: action Genre: drama Genre: comedy Genre: comedy Genre: comedy Genre: drama Genre: drama Genre: comedy Genre: comedy Genre: drama

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Python Code:

###########################################
class MovieNode:
    def __init__(self, title, year, director, genre):
        self.title = title
        self.year = year
        self.director = director
        self.genre = genre
        self.next = None
        self.prev = None

    def __str__(self):
        return f"Title:  {self.title:<25} Year: {self.year:<6} Director: {self.director:<20} Genre: {self.genre:<10}"

    def __lt__(self, other):
        if self.title < other.title:
            return True
        else:
            return False

###########################################
class MovieList:
    def __init__(self):
        self.head = None
        self.tail = None

    def display(self):
        curr = self.head
        while curr:
            print(curr)
            curr = curr.next
    
    # Append new_movie at end of MovieList
    def append_movie(self, new_movie): # simply adding book to the end of the ddl
        if self.head == None:
            self.head = new_movie
            self.tail = new_movie
        else:
            self.tail.next = new_movie
            new_movie.prev = self.tail
            self.tail = new_movie

    # Insert new_movie after curr_movie
    def insert_movie_after(self, curr_movie, new_movie): 
        if self.head is None:
            self.head = new_movie
            self.tail = new_movie
        elif curr_movie is self.tail:
            self.tail.next = new_movie
            new_movie.prev = self.tail
            self.tail = new_movie
        else:
            succ = curr_movie.next
            new_movie.next = succ
            new_movie.prev = curr_movie
            curr_movie.next = new_movie
            succ.prev = new_movie

    def get_movie(self,title):
        curr = self.head
        while curr and curr.title != title:
            curr = curr.next
        return curr
    
    #################################################
    # Task 1: implement remove_movie function
    #################################################           
    def remove_movie(self, movie): 
        #
        # your code goes here
        #    
        pass # fix this

 

if __name__ == "__main__":

    movies = MovieList()
    movies.append_movie(MovieNode('Point Break', 1991,'Kathryn Bigelow', 'action'))
    movies.append_movie(MovieNode('The Power of the Dog', 2021, 'Jane Campion','drama'))
    movies.append_movie(MovieNode('Hunt for the Wilderpeople', 2016,'Taika Waititi', 'comedy'))
    movies.append_movie(MovieNode('Jojo Rabbit', 2019, 'Taika Waititi', 'comedy'))
    movies.append_movie(MovieNode('Promising Young Woman', 2020, 'Emerald Fennell','comedy'))
    movies.append_movie(MovieNode('The Piano',1993,'Jane Campion','drama'))

    num_to_remove = int(input())
    for n in range(num_to_remove):
        to_remove = input()
        movie = movies.get_movie(to_remove) 
        if movie:
            movies.remove_movie(movie)
    movies.display()

 

In this lab, you are provided with a MovieNode class, and a partially complete MovieList class.
• A MovieList is a doubly linked list in which each element of the list is a MovieNode
• A MovieNode has the following attributes:
o title: a string, the title of the movie
o year: an integer for the year the movie was first released
o director: a string, the name of the director of the movie
• genre: a string, the genre (or category of the movie) e.g. comedy, drama, action
o next: a reference to the next MovieNode in the list, or None if it is the last in the list
o prev: a reference to the previous MovieNode, or None if it is the first in the list
Task: Complete the method remove_movie (self, movie)
• Input to the method is a MovieObject
• The method removes that MovieObject from the list
You are provided with code in___main___ for testing which prompts the user for a number of movies to remove, finds the MovieNode with
that title in the MovieList. and removes it
For example, if the list contained the following movies, printed using the MovieList method display():
Title:
oint Break
Title: The Power of the Dog
Title: Hunt for the Wilderpeople
Title: Jojo Rabbit
Title: Promising Young Woman
Title: The Piano
removing the movies with the following titles:
Point Break
Jojo Rabbit
would result in the following MovieList
Title: The Power of the Dog
Title: Hunt for the Wilderpeople
Title:
Promising Young Woman
Title: The Piano
Year:
Year: 2021
Year: 2016
Year: 2019
Year: 2020
Year: 1993
Year: 2021
Year: 2016
Year: 2020
Year: 1993
Director: Kathryn Bigelow
Director: Jane Campion
Director: Taika Waititi
Director: Taika Waititi
Director: Emerald Fennell
Director: Jane Campion
Director: Jane Campion
Director: Taika Waititi
Director: Emerald Fennell
Director: Jane Campion
Genre: action
Genre: drama
Genre: comedy
Genre: comedy
Genre: comedy
Genre: drama
Genre: drama
Genre: comedy
Genre: comedy
Genre: drama
Transcribed Image Text:In this lab, you are provided with a MovieNode class, and a partially complete MovieList class. • A MovieList is a doubly linked list in which each element of the list is a MovieNode • A MovieNode has the following attributes: o title: a string, the title of the movie o year: an integer for the year the movie was first released o director: a string, the name of the director of the movie • genre: a string, the genre (or category of the movie) e.g. comedy, drama, action o next: a reference to the next MovieNode in the list, or None if it is the last in the list o prev: a reference to the previous MovieNode, or None if it is the first in the list Task: Complete the method remove_movie (self, movie) • Input to the method is a MovieObject • The method removes that MovieObject from the list You are provided with code in___main___ for testing which prompts the user for a number of movies to remove, finds the MovieNode with that title in the MovieList. and removes it For example, if the list contained the following movies, printed using the MovieList method display(): Title: oint Break Title: The Power of the Dog Title: Hunt for the Wilderpeople Title: Jojo Rabbit Title: Promising Young Woman Title: The Piano removing the movies with the following titles: Point Break Jojo Rabbit would result in the following MovieList Title: The Power of the Dog Title: Hunt for the Wilderpeople Title: Promising Young Woman Title: The Piano Year: Year: 2021 Year: 2016 Year: 2019 Year: 2020 Year: 1993 Year: 2021 Year: 2016 Year: 2020 Year: 1993 Director: Kathryn Bigelow Director: Jane Campion Director: Taika Waititi Director: Taika Waititi Director: Emerald Fennell Director: Jane Campion Director: Jane Campion Director: Taika Waititi Director: Emerald Fennell Director: Jane Campion Genre: action Genre: drama Genre: comedy Genre: comedy Genre: comedy Genre: drama Genre: drama Genre: comedy Genre: comedy Genre: drama
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Operations of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education