Introduction to Computer Science I by James Tam Return to the course web page

CPSC 231: Assignment 7 (Worth 6%)

Due Friday April 1

New concepts to be applied in this assignment

  1. File input and output
  2. Records
  3. Arrays of records and common list management functions
  4. Sorting

Introduction

For this assignment you are to write a Pascal program that allows a person to manage their movie collection.  In the full version of the assignment your program will read the initial information from file called 'movies.dat' into an array of records.   The user can perform all the common list management functions, such as editing existing movies in the collection or inserting new movies into the collection.   When the person has finished with the program, he or she can then save the updated information back to the data file and to reload the updated information later. 

Assignment description

Each movie will be described by six fields with each field residing on a separate line (or lines in the case where there are sub-fields) in the following order:

  1. Movie name

  2. The names of the first three cast members.

  3. The genre of the movie

  4. The (age) rating of the movie

  5. The number of stars (the 'quality' rating of the movie)

  6. The director of the movie

Description of the fields

1. Movie name

The name of the movie will be stored as a string of characters up to 80 characters in length.

2. Cast

The cast list will consist of the full names of three of the actors from this film.   Each actor's name will appear on a separate line, both in the data file and when the collection is displayed onscreen. Each actor's name acts as a sub-field for this field but you can treat each person's name as one continuous string, e.g., you don't need separate fields for the first, middle and last name.  The maximum length of the name field for each actor will be 80 characters.   Thus a 2D array will to store the cast information: the rows determine which actor is being accessed while the column stores information about a particular actor e.g.,

  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] ... [80]
[1] H e a t h e r   M o r r i s    
[2] R i c h a r d   G r o s s e    
[3] D o n n a   B u r k e          

3. Genre

The genre field describes the category that the movie falls into.  There will be six different categories of movies: action, drama, science fiction, comedy, horror and martial arts.   In the input file, the genre field will consist of a string of up to fifteen characters in length.  For this assignment you can assume that the movies will fall into only one of these categories.  You can ignore the cases where a movie can be categorized into more than one genre.

4. Rating

The purpose of the rating system is to suggest or indicate how appropriate the movie is for viewers of different ages rather than as a guide to how *good* or *bad* a movie is.   According to CARA (the Classification and Rating Administration), "...the movie rating system is sponsored by the Motion Picture Association of America and the National Association of Theatre Owners to provide parents with advance information on films, enabling parents to make judgments on movies they want or do not want their children to see."  

There are six different possible types of ratings for a movie: G, PG, PG-13, R, NC-17 and NR.

G (General Audience): All ages admitted.
PG (Parental Guidance Suggested): Some of the subject matter in the movie may not be suitable for children.
PG-13 (Parents Strongly Cautioned):  Some of the subject matter in the movie may not be suitable for children under 13.
R (Restricted): People under the age of 17 (ages may vary by location) require an accompanying parent or adult guardian to view the movie.
NC-17: No one under the age of 17 (again ages may vary by location) will be admitted regardless of who accompanies them. 
NR (Not rated): The movie has not yet been rated.
In the input file, the rating field will reside on a line by itself and it will take the form of a string of up to 5 characters in length ('G', 'PG', 'PG-13', 'R', 'NC-17', 'NR').

5. Number of stars

This field rates each movie according to how good or bad that I thought it was1.  The greater the number of stars, the better the movie.  In the input file the number of stars that a movie received will be specified by an integer ranging from one to five.

    1 star (It sucks): It's not the type of movie that's so bad that it's good, it's just all bad.  Don't  
    waste your time with this one.

    2 stars (Poor): Overall there were more things that I disliked than liked with this movie.   
    Unless there's a ticket sale it's probably one that you should avoid.

    3 stars (Average):  There were some things that I liked and some things that I disliked.  It's one
    that you may want to rent rather than buy.

    4 stars (Good): This movie has some flaws but overall you'll have a great time watching it.

    5 stars (A true masterpiece!):  OMG!  I laughed, I cried, it became a part of me.  It should definitely 
    be nominated for an Oscar (maybe several).

1.  JT: The number of stars given to the movies in the input file was based solely upon my opinion and does not necessarily reflect the opinions of the university so please don't write angry letters outrage  because you thought I didn't properly rate your favorite flick

6. Director

The name of the director will be a string up to 80 characters in length.  As was the case with the cast names, the director's name may include a first, middle and last name but you can store all of this information in a single character array.

The six main fields for each movie will be followed by a line of stars (which of course contains an end-of-line marker):

TERMINATOR 2 JUDGMENT DAY
Arnold Schwarzenegger
Linda Hamilton
Edward Furlong
Action
R
5
James Cameron
************
IT'S A WONDERFUL LIFE
James Stewart
Donna Reed
Lionel Barrymore
Drama
NR
5
Frank Capra
************
ROMEO AND JULIET
Leonard Whiting
Olivia Hussey
John McEnery
Drama
PG
5
Franco Zeffirelli
************

The lines of stars are not to be read into the array of records.  It is used only to visually separate the movies in the input file.

Grades for working assignments:

Basic assignment: C

Your program reads the information from the input file 'movies.dat'  into the array.   The contents of that array can be displayed onscreen with write's and writeln statements.  Each movie will be separated onscreen by a line of tildes '~'.  To prevent the output from scrolling off the screen your program should 'pause' the display of movies ever so often (say after displaying every 3rd or 4th movie) while it waits for a response from the user to tell it to continue (e.g., 'Hit return to continue').  The output must be displayed in a neat and legible format (try running the sample executable for an example).    Finally your program must be able to write the movie list back to a file called "modifiedMovies.dat".  The line of stars that separated each movie in the input file must be written back to the output file.   Similar to previous assignments, your program has menu driven interface.  The basic program should display a menu similar to the one shown below:

Movie Manager: Menu options

(d)isplay collection

(l)oad a collection from disk

(s)ave the collection to disk

(q)uit the program

You should add additional menu options as you implement the extra features that are listed below.

Extra features: 

Completion of each of these extra features will result in the increase of a "one step" to your grade e.g., 'C' to 'C+'.  Except for features two, four  and six you can complete as many of the features below as you wish in whatever combination that you desire.   In the case of those three features you must have completed feature two before you can get credit for feature four or six.   Successful completion of all seven features will make you eligible for an A+.   (You must also fulfill style requirement as well as the general submission assignment requirements).

Feature one (Alphabetize the movie list according to title):

Sort the movie list into alphabetical order according to the movie's name.

Feature two (Find additional details about a movie):

The user of the program can type in the name of the movie (case sensitive) to find additional information about that movie .  If the movie is not in the list, then your program should indicate that the movie could not be found under that title.  If the movie is in the list, then your program will display additional details about that movie (all the fields of that movie will be displayed onscreen).

Feature three (Present all movies that meet a certain criteria):

This feature allows the user of the program to display onscreen only movies that meet a specific criteria for one of the six fields.  To fulfill the requirements for this feature you need to implement the 'present movie' feature for one of the following cases (but you won't get additional marks for implementing more than one case): 

    Rating: The user can type in one of the rating categories (case sensitive)  and your program will display all 
    movies with that rating.

    Genre: The user can type in a genre  (case sensitive) and the program will list all the movies that fall in the 
    genre specified by the user.

    The number of stars received:  The user can type in a numerical value that indicates the 
    minimum acceptable number of stars that a movie must have.  The program will then 
    present only those movies that received the specified number of stars or greater.  

If you have already completed feature one, then the movies will be presented in alphabetical order, otherwise they will presented in the order in which they currently appear in the array.  

Feature four (Edit movie information - requires that you have already completed feature two):

Edit the information for a movie in the list.  In order to complete the requirements for this feature you must have completed feature two because the user of the program must indicate to the program which movie that they wish to edit by entering the name of the movie and the program searches for that movie.  When the edit movie feature is selected, the user of the program will then be able to re-enter the information for all the fields of that movie one field at a time.

Feature five (Insert a movie at the end of the list):

When this feature is selected by the user, he or she will prompted to enter in information for all the fields of the new movie.  The new movie will then be added to the end of the list.

Feature six (Remove a movie from the list - requires that you have already completed feature number two):

Again, the user must type in the name of the movie in order to indicate which movie that he or she wishes to remove from the list so you need have complete the lookup contact feature first (feature two).  When the collection is displayed, no information about that movie should be displayed - not even blank spaces.  You can implement this feature by either shifting the array elements that follow the element to be deleted 'up' or you may be able to add an additional attribute for each array element that indicates whether it has been deleted or not (I'd recommend the first approach).

Feature seven (Write an enhanced Save feature)

In order to get credit for this feature, the program will now use only one data file.  The program will load the movie information from the "movies.dat" file.  When the user of the program selects the 'save' option then the program will write the modifications to the "movies.dat" file rather than a separate "modifiedMovies.dat" file.  To get credit for this feature your program must be able to reload the updated information as well.   This latter requirement means that your program must write the information to disk in the exact same format that it was originally stored.  If there any differences from the original data file and the modified version your program will not be able to properly read it back into the array.

Grades for non-functional assignments

D level assignment

The student has invested considerable work in the assignment and the code compiles but it doesn't fulfill any of the above requirements.

D- level assignment

The student has invested considerable work in the assignment but it doesn't compile.

Other submission requirements

  1. Good coding style and documentation:  They will play a role in determining your final grade for this assignment.  Your grade can be reduced by a letter step or more if your submission was implemented using bad style conventions (e.g., 'A' to 'A-' for employing poor naming conventions for identifiers, insufficient documentation, the use of global variables, using non-modular design or having an excessively large amount of redundant code in your program).

  2. Include a README file in your submission:  For this assignment your README file must indicate what grade level that you think your assignment should receive (e.g., 'A', 'B' or 'C') and the features that you have implemented.  This will allow your marker to quickly determine what he or she must look for and speed up the marking process.

  3. Assignments (source code dot-p files and the README file) must be electronically submitted via submit.  In addition a paper print out of the source code and README must be handed into the assignment drop box for the tutorial that you are registered in (located on the second floor of the Math Sciences building).  Electronically submitting the assignment allows your marker to run the code in order to quickly determine what features were implemented.  Providing a paper printout makes it easier for your marker to read and flip through your source code.

Relevant Files

In the directory for this assignment you will be able to run a sample executable called "movies".  It has all features of this assignment working with only a slight modification.  Because you won't have permission in Unix to write updates to the assignment directory I've disabled feature #7 for this version.  In this directory you will also find the full input file called "movies.dat" as well as a smaller form of the input file called "miniMovies.dat".  The program that you hand for marking must be able to run using the full input file but you can use the second file, which is smaller, for testing purposes.