(Solved) : 71 Special Methods Inheritance Purpose Completing Assignment Practiced Overloading Operato Q44063370 . . .
7.1 Special Methods and Inheritance
Purpose:
After completing this assignment, you will have practicedoverloading operators for a programmer-defined class and usinginheritance.
Description
For this assignment you will write a program to simulate a medialibrary. We will work with three types of media: pictures, music,and movies. Your job is to design and implement a class hierarchyconsisting of the Media, Picture, Song, and Movie classes, asdescribed below.
Specification for the classes:
Media class
The Media class will be the abstract base class to be inheritedby our Song, Movie and Picture classes. All Media objects shouldhave a name and a rating. The rating is an integer number (think ofthis as the number of stars given).
We will leave many design decisions to you, however you shouldimplement at least an __init__ and __str__ method as well as a*static abstract method, add().
Movie class
A Movie is a type of Media that has a director and running time(given in minutes). This class has a play() method that willsimulate the task of playing a movie (you can do something simpleas printing: ‘<>, playing now’. The Movie class shouldoverride the __str__(or __repr__) method of Media. Make sure youalso implement any other methods (such as __init__, getters, andsetters) as needed by Movie. You should be able to use the __str__(or __repr__)method in a script to show all the movie information,including media type, name, rating, director, and running time.
In addition you should have a add static methodthat prompts the user to enter the necessary information to createa Movie object, and returns a new instance of that object.
Song class
A Song is a kind of Media that has an artist and an album. Thisclass has a play() method that will simulate the task of playing asong (you can do something simple as printing something like:‘<> by <>, playing now’. The Song class should overridethe __str__ (or __repr__) method of Media. Make sure you alsoimplement any other methods (such as __init__, getters, andsetters) as needed by Song. You should be able to use the __str__(or __repr__)method in a script to show all the song information,including media type, name, rating, artist, and album.
In addition you should have a add static methodthat prompts the user to enter the necessary information to createa Song object, and returns a new instance of that object.
Picture class
A Picture is a kind of Media that has a resolution. Theresolution of a picture is an integer number that measures the dotsper inch (the minimum resolution of any picture should be 200 dpi).This class has a show() method that will simulate the task ofdisplaying a picture (you can do something simple as printing:‘Showing <>’. The Picture class should override the __str__(or __repr__) method of Media. Make sure you also implement anyother methods (such as __init__, getters, and setters) as needed byPicture. You should be able to use the __str__ (or __repr__)methodin a script to show all the picture information, including mediatype, name, rating, and resolution.
In addition you should have a add static methodthat prompts the user to enter the necessary information to createa Picture object, and returns a new instance of that object.
Script
Your script will simulate a media library. To interact with ityou should have a menu that allows the user to perform thefollowing actions:
- Display all items in the Media library
- Display only the Song objects
- Display only the Movie objects
- Display only the Picture objects
- Play a Song: the user enters the name of the Song. If the Songis found play it. If not, display a message indicating that theSong is not in the media library.
- Play a Movie: the user enters the name of the Movie. If theMovie is found play it. If not, display a message indicating thatthe Movie is not in the media library.
- Display a Picture: the user enters the Picture. If the Pictureis found display it. If not, display a message indicating that thePicture is not in the media library.
- Add a Song. You will then be prompted to enter a song title, anartist, and a rating.
- Add a Movie. You will then be prompted to enter a the moviename, director, running time, and rating.
- Add a Picture. You will then be prompted to enter a photo name,resolution, and rating.
- Quit the program
You will need a loop to show and process the menu until the userchooses to quit/exit the program. The options are of the format .Option. To see the expected I/O, submit your code (you getunlimited submissions), after which you will see the expectedoutput given a particular input.
Expert Answer
Answer to 7.1 Special Methods and Inheritance Purpose: After completing this assignment, you will have practiced overloading opera…
OR