联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2018-08-01 04:08


ICS 31, Summer Session 10-WK, 2018

Lab 3

You will write a basic movie management system. Your program will let the user to enter

information about set of movies and then issue commands to edit or sort information about the

movies.

You will implement a simple shell program which will allow the user to enter commands. Your

program should print out a prompt to indicate that the user can enter a command. Your prompt

should be a ‘$’ character. At the prompt the user will type a command followed by a set of

arguments for the command. Your program will perform whatever action is indicated by the

command, and then your program will print a ‘$’ character on a new line in order to let the user

know that he/she can type a new command.

Your program should accept the following commands.

1. addmovie: This command indicates that the user wants to enter the information about a

new movie into the system. This command takes no arguments. When this command is

issued, the shell will prompt the user for 4 pieces of information about the movie: the

movie title, the year released, IMDB rating (a float), and the directors name, separated

by commas. This command adds the information about the new movie into the system.

2. printmovies: This command prints all the information about the movies which have

been entered into the system. This command takes no arguments. The information

about each movie is printed on a separate line. Each line should have four pieces of

information on it: the movie title, the year released, IMDB rating, and the directors name,

separated by commas.

3. deletemovie: This command indicates that the user wants to delete the information

about a movie from the system. This command should be followed by one argument, the

name of the movie.

4. sortratings: This command indicates that the user wants to view the movies based on

the ratings given by IMDB. This command takes no arguments. This command will print

the information about the movies which have been entered into the system, sorted by

their IMDB ratings. The information about each movie is printed on a separate line. Each

line should have four pieces of information on it: the movie title, the year released, IMDB

rating, and the directors name, separated by commas.

5. findyear: This command searches for all books with a certain release year. The

command should be followed by one argument, the release year. For each movie in the

system with the given release year, the movie’s information should be printed on a single

line: the movie title, IMDB rating, and the directors name, separated by commas.

6. findmovie: This command searches the system for a movie with a certain name. The

command should be followed by one argument, the name of the movie. If a movie with

the given name is in the system, the movie’s information should be printed on a single

line: the year released, IMDB rating, and the directors name, separated by commas.

7. quit: This command should end the program

Example Output

The following output is an example of how your program should respond to commands. The text

typed by the user is in bold.

$ addmovie

Movie Title: Avengers Infinity War

Year Released: 2018

IMDB Rating: 8.8

Director: Anthony Russo, Joe Russo

$ addmovie

Movie Title: Thor Ragnarok

Year Released: 2017

IMDB Rating: 7.9

Director: Taika Waititi

$ addmovie

Movie Title: Doctor Strange

Year Released: 2016

IMDB Rating: 7.5

Director: Scott Derrickson

$ addmovie

Movie Title: Deadpool 2

Year Released: 2018

IMDB Rating: 8.3

Director: David Leitch

$ printmovies

Avengers Infinity War, 2018, 8.8, Anthony Russo, Joe Russo

Thor Ragnarok, 2017, 7.9, Taika Waititi

Doctor Strange, 2016, 7.5, Scott Derrickson

Deadpool 2, 2018, 8.3, David Leitch

$ deletemovie Thor Ragnarok

$ sortratings

Avengers Infinity War, 2018, 8.8, Anthony Russo, Joe Russo

Deadpool 2, 2018, 8.3, David Leitch

Doctor Strange, 2016, 7.5, Scott Derrickson

$ findyear 2016

Doctor Strange, 7.5, Scott Derrickson

$ findmovie Deadpool 2

2018, 8.3, David Leitch

$ quit

Additional Details

• The commands and arguments should be case-sensitive.

• If the user enters a command which is not valid, your program should not crash. Instead,

your program should ignore the command without changing the state of the book

database, and print a new prompt for the user.

• Your program will need to maintain a list which contains information about al movies.

Name that list movielist.

• Each item in movielist should be a named tuple which contains all information about

a movie. The namedtuple should have 4 fields: the movie title, the year released, IMDB

rating, and the directors name.

• The addmovie command should add a namedtuple to movielist, and the

deletemovie command should remove a namedtuple from movielist.


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp