CP164 Final: The Movie Class

42 views2 pages
13 Jun 2018
School
Course
Professor
The Movie Class
The Movie class must contain the following methods:
a constructor that accepts the movie attribute values as parameters
a string accessor (i.e. converts the movie attributes to a formatted string)
comparison methods for ==, <, and <=
a write method that writes a movie's attributes to a file
A typical movie should be output as a string in the format:
Title: Dark City
Year: 1998
Director: Alex Proyas
Rating: 7.8
Genres: science fiction
Movies are sorted by title, then by year. Thus, Zulu, 1964, comes before Zulu, 2013.
The outline of the Movie class is:
"""
-------------------------------------------------------
Movie class definition.
-------------------------------------------------------
Author: cash duke
ID: 999999999
-------------------------------------------------------
"""
class Movie:
"""
-------------------------------------------------------
Constants
-------------------------------------------------------
"""
MIN_RATING = 0
MAX_RATING = 10
FIRST_YEAR = 1888
GENRES = ("science fiction", "fantasy", "drama",
"romance", "comedy", "zombie", "action",
"historical", "horror", "war")
# Defines a range of valid integer genre codes:
GENRE_CODES = range(len(GENRES))
def __init__(self, title, year, director, rating, genres):
"""
-------------------------------------------------------
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents

Related Questions