|
发表于 12-2-2019 04:06 PM
|
显示全部楼层
|
|
|
|
|
|
|
楼主 |
发表于 13-2-2019 03:02 PM
|
显示全部楼层
已经解决了
|
|
|
|
|
|
|
|
楼主 |
发表于 16-6-2019 04:26 PM
|
显示全部楼层
Question: During the printing of the movie details, all parts of the code that prints the movie details shall be replaced by the PrintMovieDetails() function created without any changes to the existing format of displaying the movie details.
For example:
Name: The Avengers
Category: Fantasy
Description: Earth's mightiest heroes must come together and learn to fight
as a team if they are going to stop the mischievous Loki and his alien army from enslaving humanity..
Price: $16.5
青色部分是要用PrintMovieDetails(movie)的function来显示的,要怎么更改现有的code来call这个新function?
def PrintMovieDetails(movie):
print("Name: "+movie.getName())
print("Category: "+movie.getCategory())
print("Description: "+movie.getDescription())
print("Price: $"+str(movie.getPrice()))
def menu1():
print("\n\nDisplay all movies")
index = 0
usrInput = ""
while usrInput != "M":
try:
print("\nMovie "+str(index+1)+" of "+str(len(listOfMovies)))
print("==============================")
#use new function to display the movie details
print("Name: "+listOfMovies[index].getName())
print("Category: "+listOfMovies[index].getCategory())
print("Description: "+listOfMovies[index].getDescription())
print("Price: $"+str(listOfMovies[index].getPrice()))
print("==============================")
print("Enter N for Next movie")
print("Enter P for Previous movie")
usrInput = input("Enter M to return to Main Menu\n")
if usrInput == "N":
index += 1
if index >= len(listOfMovies):
index = 0
elif usrInput == "P":
index -= 1
if index < 0:
index = len(listOfMovies)-1
except Exception as e:
print("IndexError occurred")
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|