Question: in python Purpose: After completing this assignment, you will have practiced overloading operators for a programmer-defined class and using inheritance. Description For this assignment you

in python

Purpose:

After completing this assignment, you will have practiced overloading operators for a programmer-defined class and using inheritance.

Description

For this assignment you will write a program to simulate a media library. We will work with three types of media: pictures, music, and movies. Your job is to design and implement a class hierarchy consisting of the Media, Picture, Song, and Movie classes, as described below.

Specification for the classes:

Media class

The Media class will be the abstract base class to be inherited by our Song, Movie and Picture classes. All Media objects should have a name and a rating. The rating is an integer number (think of this as the number of stars given).

We will leave many design decisions to you, however you should implement 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 will simulate the task of playing a movie (you can do something simple as printing: <>, playing now. The Movie class should override the __str__(or __repr__) method of Media. Make sure you also implement any other methods (such as __init__, getters, and setters) 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 method that prompts the user to enter the necessary information to create a 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. This class has a play() method that will simulate the task of playing a song (you can do something simple as printing something like: <> by <>, playing now. The Song class should override the __str__ (or __repr__) method of Media. Make sure you also implement any other methods (such as __init__, getters, and setters) 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 method that prompts the user to enter the necessary information to create a Song object, and returns a new instance of that object.

Picture class

A Picture is a kind of Media that has a resolution. The resolution of a picture is an integer number that measures the dots per inch (the minimum resolution of any picture should be 200 dpi). This class has a show() method that will simulate the task of displaying 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 any other methods (such as __init__, getters, and setters) as needed by Picture. You should be able to use the __str__ (or __repr__)method in a script to show all the picture information, including media type, name, rating, and resolution.

In addition you should have a add static method that prompts the user to enter the necessary information to create a Picture object, and returns a new instance of that object.

Script

Your script will simulate a media library. To interact with it you should have a menu that allows the user to perform the following 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 Song is found play it. If not, display a message indicating that the Song is not in the media library.
  • Play a Movie: the user enters the name of the Movie. If the Movie is found play it. If not, display a message indicating that the Movie is not in the media library.
  • Display a Picture: the user enters the Picture. If the Picture is found display it. If not, display a message indicating that the Picture is not in the media library.
  • Add a Song. You will then be prompted to enter a song title, an artist, and a rating.
  • Add a Movie. You will then be prompted to enter a the movie name, 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 user chooses to quit/exit the program. The options are of the format . Option. To see the expected I/O, submit your code (you get unlimited submissions), after which you will see the expected output given a particular input.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!