Lecture notes for the Introduction to Computer Science II by James Tam Return to the course web page

CPSC 233: Assignment 3

New concepts to be applied for the assignment

  1. Dynamic (singly linked) lists

File input and output is not necessary for this assignment.

Writing a list management program

For this assignment you are to write a program that allows a person to manage their movie collection. The full version will perform some common list management functions such as: adding, displaying, removing or searching. Because this is a linked list implementation there should not be a limit on the number of movies that can be added.

Each movie will be described by four fields:

  1. Movie name

  2. The names of the first three cast members.

  3. The genre of the movie

  4. The number of stars (the rating of the movie)

Description of the fields

1. Movie name

This field consists of an alpha (and sometime numeric string e.g., Star Trek 2 as an alternative to Star Trek II).

2. Cast

The cast list will consist of the full names of three of the actors from this film.  A 1D array of strings can be used to store the cast information e.g.,

[0] H e a t h e r   M o r r i s    
[1] R i c h a r d   G r o s s e    
[2] 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, martial arts or 'other'. You don't have worry about checking for instances where a movie falls into multiple genres.

4. Rating

This field uses a number of stars to rate each movie according to its entertainment value1.  The greater the number of stars, the better the movie:

    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/stream 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!): I laughed, I cried, it became a part of me.  It should definitely 
    be nominated for an Oscar (maybe several).

When movies are displayed each field will reside on a separate line and each movie will be separated by a line of stars (but the stars are not an attribute of a movie object).

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

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 favourite flick ☺. 

Features to be implemented (you will also be graded on other criteria such as coding style and providing program documentation as listed in the marking guide): 

 
  1. Displays an introduction to the program that describes how it works each time that it's run.
 
  1. Displays a sign off exit message to indicate to the user that the program has ended.
 
  1. Defines class 'Movie' that with the 4 attributes described above.
 
  1. Defines class 'MovieNode' (analogous to 'BookNode' from my notes on linked lists) which is a class with two fields: a) 'Data' which is of type 'Movie' b) 'Next' which is a reference to a MovieNode (next node in the list or null for the end of the list).
 
  1. Declares a head reference/pointer of type 'MovieNode' which is initialized to null. To get credit for this feature you just need to outline the attributes and (empty) methods. You will get credit for implementing the methods in features 11 - 15 below).
 
  1. Defines a 'manager' class which will include methods for all the list operations e.g., add, remove, search, display. Your first step is to define this class with just the method signatures and empty methods. Later you can fill in the method bodies (feature #10, 13, 14, 15).
 
  1. Implements some form of debug mode (i.e., it has a debugging variable that will display some sort of debugging message when the program is in debug mode). The particulars of your messages are left to your discretion, the main idea is that these messages provide information to help you find and fix the errors in your program and only appear when the program is in the debugging state.
 
  1. Displays a menu listing the features available. (The menu options don't have to be functional yet, to get credit for this the feature the menu just has to be displayed).
 
  1. The program repeats until the user quits. Each time that the program repeats the main menu (above) is displayed. The (Q)uit menu option has been implemented.
 
  1. (A)dd a movie to the collection: You are to implement one of two versions of the add feature. (You only get credit for one feature or the other). In both cases the program will prompt the user to enter each field one-at-a-time. Although the program doesn't have to check for duplicate movies it should error check the genre and the rating when new movies are added. (See the next two features). The add feature must be implemented before you can get credit for any of the other features that follow it.
   
  1. The simple version will add new movies to the end of the list.
   
  1. The advanced version will insert movies in ascending order of name. (You can use the String method 'compareToIgnoreCase' to determine ordering)
 
  1. (When add feature is invoked): The genre should only be one of the types listed above. If not the program should continue prompting the user for a valid value until either a valid one is entered or the person signals that they wish to cancel adding a new movie (by just hitting enter - blank genre - during the error handling loop).
 
  1. (When the add feature is invoked): The program should check that the rating is a value between one and five. If not then the program should continue prompting the person for the number of start until either a legitimate value is entered or the person enters a negative value (to signify that they wish to cancel this option).
 
  1. (D)isplay implemented: Each movie will be separated onscreen by a line of stars.  When the list of movies is long, to prevent the output from scrolling off the screen your program should 'pause' the display of movies every so often (say after displaying every 10th movie) while it waits for a response from the user to tell it to continue (e.g., 'Hit enter to continue').  The output must be displayed in a neat and legible format (try running the sample executable for an example).  The program should display an appropriate status message if the list is empty (e.g., "List is empty: nothing to display"). (JT's hint: you should implement this feature soon after you complete the add feature because it's essential for testing the other features).
 
  1. (S)earch: The user types in the name of the movie (case insensitive) to  see full information about that movie.  If the list is empty then the program should inform the user of this fact and no search should be performed.  If the movie is not in the list, then your program should indicate that the movie could not be found under that name.  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).
 
  1. (R)emove a movie from the list: You can implement one of two versions of this features (you only get credit for one). In both cases the program should produce some sort of error message if the list is already empty when this feature is invoked.
   
  1. The simple version will just remove the last node from the list.
   
  1. The advanced version will prompt the user for the name of the movie to remove. The program will then search for and remove the first instance of that movie (case insensitive search). Similar to the search feature an appropriate status message should be displayed if no matches were found.

  

Submitting your work:

  1. Assignments (source code/'dot-java' files) must be electronically submitted according to [the assignment submission requirements].  For this assignment you need to create a UML class diagram that shows: the classes implemented, their relationships as well the attributes/methods and their access permissions. Individual classes must show the 'full information' for each method (parameter names and types as well the return type). Class diagrams can be drawn by hand and scanned, or drawn electronically. You are to electronically submit the class diagram along with your source code (make sure you don't forgot to submit all the dot-Java files).
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].
  3. Before you submit your assignment to help make sure that you haven't missed anything here is a [checklist] of items to be used in marking.

 

External libraries that can be used

  1. Libraries that allow for text-based (console) input and output. You cannot use any libraries that implement a linked list class (whether that library was written by Sun/Oracle or someone else). These libraries are the ones that have full implementations for the list operations and the point of the assignment is to learn how these operations work by implementing them yourself. Also the assignment is to give you addition practice/insight into references/pointers.
  2. Class String and it's accompanying methods can be used.