Question: Aim Create a class that represents a portable movie player, MoviePlayer. The MoviePlayer class should have a play method, which sets the first movie from
Aim
Create a class that represents a portable movie player, MoviePlayer. The MoviePlayer class should have a play method, which sets the first movie from the list of movies as currently playing. The list of movies should be a private attribute. Additionally, it should have a firmware version attribute and an update firmware class method that updates the firmware version.
Steps for Completion
Go to your main.py file.
Define the MoviePlayer class by adding the firmwareversion class attribute and assigning it a value of
Define the initializer method init and prepopulate the movie list with a few movies. Make sure the movies store is private.
Define the play method, which sets the currentmovie attribute to the first item in the movies list.
Define the listmovies method, which returns the list of movies in the MoviePlayer.
We'll add the updatefirmware version method, which checks for whether the new version being provided is more recent than the current firmware version before updating.
We then add a few test lines to the main method and run the script as shown in Snippet :
player MoviePlayer
printMovies currently on device:", player.listmovies
player.updatefirmware
printUpdated player firmware version to player.firmwareversion
player.play
printCurrently playing", fplayercurrentmovie
Snippet
We can run the script by entering python main.py in the terminal. The output should look similar to Figure :
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
