Question: I need to make a python program that executes something like this: What needs to be done is to make a python program that gets

I need to make a python program that executes something like this:

What needs to be done is to make a python program that gets the name of the song, title, artist, album name, run-time, last-time played from a music file in your directly and the file should also have a rating system for itself

it should look like this in the main.py while everyhting should be in a class on its own in song.py

Your song abstraction should include the following:

  • A way to get a description of the song. Example:

Crazy by Gnarls Barkley from the album St. Elsewhere added on 2019-09-01. Runtime is 3:02.

Where the items in bold describe a specific song on the playlist (title, artist, album, date added, runtime). These items must always be set for the song (i.e., they cannot be undefined or empty).

  • A way to get the location of the audio file. This returns the pathname and filename for the audio file. This information must be set when the Song is created, and cannot be undefined or empty.
  • Ability to update the play count for the song, ie, the number of times this song has been played.
  • A way to get and set a user rating for the song.
  • The description of the song should show like this after it has been played:

Crazy by Gnarls Barkley from the album St. Elsewhere added on 2019-09-01. Runtime is 3:02. Last played on 2019-09-16.

... and like this after it has been rated ...

Crazy by Gnarls Barkley from the album St. Elsewhere added on 2019-09-01. Runtime is 3:02. Last played on 2019-09-16. User rating is 3/5.

  • A way to play the song (currently this will do nothing more than update the last played date and the play count).
  • Any methods (including the constructor) with parameters MUST have parameter validation to make sure undefined, invalid or empty values are not accepted (as per the requirements). Raise a ValueError exception with descriptive error message in those cases.
    • if validation becomes overly long or obfuscated, or is required in multiple places, consider moving it into a private method (prefix with double underscore). We do this so that the validation function does not become part of the class level interface.
  • Testing

    Instructions:

  • Create a new main Python script for the testing of your class. The file should be called main.py and have a main function.
    • Make sure you import your Song class
  • Create tests for each of the public methods in your class, including your constructor.
    • Make sure to cover all success cases for the method. This is where the method returns an expected result.
    • Cover at least one error case for the methods that take in parameters. An example is if you pass in an invalid parameter where an exception should be raised.
    • You may only use other public methods to verify the results of your test. DO NOT access private attributes directly.

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!