Question: I need to make my make my program I started to make sure this will function: I need this to do A way to get

I need to make my make my program I started to make sure this will function: I need this to do

  • 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).

I then need to test it with:

should pass in (to the constructor) the full pathname to the mp3 file, for example: "C:\Users\man\Music\crazy.mp3", and the file should really exist (ie: you should check for file existence using os.path.exists()). If you want to make your testing repeatable, create a folder called Music in your PyCharm project, and the use a relative path for testing, such as ".\Music\crazy.mp3".

the instructions do not call for a way to retrieve the play count, but you should probably make play_count a property, or add a get_playcount() method - otherwise there is no way to check that it increments correctly.

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

The python code I have so far is:

class Song: def __init__(self, title:str, artist:str, runtime:str, album:str, release_date:str, last_played:str, times_played:int): # A CONSTRUCTOR FOR COURSE CLASS try: self._title=title self._artist= artist self._runtime = runtime self.album= album except ValueError: print("Need a proper song") self._release_date = '' self._last_played = '' self._times_played = 0 self.pathname = '' self. filename = ''

creating a Python programming

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!