Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Movie.py classThe Movie . py file will contain the definition of a Movie.We will define the Movie attributes as follows:title - str that represents the
Movie.pyclassTheMoviepyfile will contain the definition of a Movie.We will define the Movie attributes as follows:titlestrthat represents the title of the movie.Your program should ensure this field will be stored as a Python title usestrtitlemethodyes you will havetitletitlein your code :genrestrthat represents the genre of the movie.Your program should ensure that this field will be stored in all uppercase characters.yearintthat represents the release year of a movie.You will write a constructor that allows the user to construct a Movie object by passing in values for all of the fields.Your constructor should set these attributes with the valueNoneby default.initself title, genre, yearIn addition to your constructor, your class definition should also support setter methods that can update the state of the Movie objects:setTitleself titlesetGenreself genresetYearself yearEach Movie object should be able to call a methodtoStringthat you will implement, whichreturns astrwith all the movie attributesEXACTLY as shown ie the string should contain all attributes in the following EXACT formatTitleGENRE YEAR:movie MovieAbout time", "Drama", printmovietoStringprint # separate two movies with a newlinemovie Movieeternal sunshine of the spotless mind", "SciFiprintmovietoStringOutput:"About Time" DRAMA"Eternal Sunshine Of The Spotless Mind" SCIFIIMPORTANT:ThetoStringreturn value in the example above doesnotcontain a newline character
at the end.MovieList.pyTheMovieListpyfile will contain the definition of a single MovieList object.AnMovieListobject will contain a dictionary structure where the keys of the dictionary will be astrtype representing a Movies genre all uppercase charactersThe dictionary value will be a list of Movie objects that the MovieList contains. Note that the order of the Movies in the list is based on when the Movie object was inserted into the dictionary structure most recent Movie inserted will be at the end of the listYour code should support the following constructor and methods:initself Constructor that initializes the dictionary structure of the MovieList class. Initially, this dictionary should be empty.addMovieself movie Adds a Movie object movie to the MovieList. The inserted Movie object should be added to the end of the list of existing movies that are of the same genre. You may assume that a movie with the same attributes does not already exist in the MovieList when this method is called.removeMovieself movie Removes a Movie object movie from the MovieList if it exists. Your code will need to check that the provided parametermovieobject has the same attributes title genre, year as an existing movie in the MovieList, if it is to be removed from the MovieList.removeGenreself genre Removes all movies of a certain genre from the MovieList if it exists. Your code will need to remove the genre entry from the MovieLists dictionary. Note: the providedgenreparameter value may be input in either lower upper case.getMoviesByGenreself genre Returns a string of all movies of a certain genre. This string should consist of a collection of strings one line for each movie.Since each movie will be in its own line within a single string, a newline character
should be inserted between each line if applicable EXCEPT at the very last line where no newline character should exist.The order of the Movies in this string will be dictated by the order of the Movies in the MovieLists list for the Movies genre.The MovietoStringmethod should be used when constructing this methods return string.If no Movies of the specified genre exist in the MovieList, then this method returns an empty string Note: thegenreparameter value may be in either lower upper case.doesMovieExistself movie Returns a BooleanTrueif the parametermoviewith matching title, genre, year exists in the MovieList. ReturnsFalseotherwise
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started