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 firmware_version class attribute and assigning it a value of 1.0.
Define the initializer method __init__ and pre-populate the movie list with a few movies. Make sure the movies store is private.
Define the play method, which sets the current_movie attribute to the first item in the movies list.
Define the list_movies method, which returns the list of movies in the MoviePlayer.
We'll add the update_firmware 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 7.67:
player = MoviePlayer()
print("Movies currently on device:", player.list_movies())
player.update_firmware(2.0)
print("Updated player firmware version to", player.firmware_version)
player.play()
print("Currently playing", f"'{player.current_movie}'")
Snippet 7.67
We can run the script by entering python3 main.py in the terminal. The output should look similar to Figure 7.6:

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 Programming Questions!