Starting from:

$35

Full Assignment 5 Solution

New concepts to be applied for this assignment:
Dynamic (singly linked) lists
File input and output is not necessary for this assignment. The data for the lists will be manually entered by the user at run time. The program won't save the list contents to file.
Description:
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. There should not be a limit on the number of movies that can be added.


Each movie will be described by four fields:

Movie name
The names of the first three cast members
The genre of the movie
The number of stars (the rating of the movie)

Description of the fields
Movie name

This field consists of an alpha (and sometime numeric string e.g., "STAR TREK II" can also be titled as "STAR TREK 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





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.

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
4
************
<style="line-height: normal"=""ONCE UPON A TIME A HERO IN CHINA
Charine Chan
Tony Leung Kai Fai
Peeking Duck aka James Tam
Martial Arts
3
************
1. JT: The number of stars given to the movies in the example 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 ☺.

Classes
The basic structure is very similar to the Dice/User interface program to be covered in tutorial:

Driver: contains the main method which kicks things off by calling a 'start' method of class UserInterface.
UserInterface: handles user input and output, the start method will likely contain the main program loop that only ends when the user quits the program. To actually change or view the list the user interface class will invoke methods of class Manager. These operations must not be directly implemented in the user interface.Manager: handles all list operations such as adding, removing etc.MovieNode: A linked list node whose data attribute is a movie.Movie: Stores data associated with an individual movie (instances contains the 4 attributes associated with a movie such as name, cast etc.)Program features

Displays an introduction to the program (describes how it works) each time that it's run.

Displays a sign off exit message to indicate to the user that the program has ended.

Defines class 'Movie' with the 4 attributes described above.

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 aMovieNode (next node in the list or null for the end of the list).

Defines a 'Manager' class which will include methods for all the major list operations e.g., add, remove, search, display. Your first step is to define this class with empty methods. Later you can fill in the method bodies for the major list operations (feature #11, 14, 15, 16, 17) and the 'helper' methods for feature #10 (helper methods are features #12, 13).

Declares a head reference/pointer of type 'MovieNode' which is initialized to null. The head reference is an attribute of the Manager class.

Defines a 'UserInterface' class which is responsible for all interactions with the user (displaying program options, getting user input). This class does not implement the same operations as the manager class! The user interface class is responsible for displaying a menu of features available (#8 below), getting the user's selection, checking the validity of the input and determining the option selected. This class should not include the actual code for changing/displaying the list itself. Once the appropriate menu option has been determined (e.g., 'a') then the user interface class will tell class manager to run the appropriate method (e.g., 'addNode()'). In tutorial the TA's covered an example program that approximately mimics how the UserInterface class and the Managerclass interact. In that example the 'GameInterface' class will be analogous to the 'UserInterface' class and the 'Dice' class will be roughly analogous to the 'Manager' class. To get credit for the UserInterface class definition (feature #7) you simply have to outline the empty methods and attributes. Credit for implementing those methods are part of feature #8, 9 and several methods associated with #10.

(Class UserInterface method): 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).

(Class UserInterface method): 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.

(Other methods of class UserInterface): Checks that the user's menu selection was valid and if so it determines what option was selected (likely through branching).

(Class Manager method) (A)dd a movie to the collection: You are to implement one of two versions. (You only get credit for one version 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.


The simple version will insert new movies at the end of the list.


The advanced version will insert movies in ascending order of name (in-order insertion). You can use the String method 'compareToIgnoreCase()' (i.e., case insensitive) to determine ordering. Note: an in-order insertion is NOT the same as sorting the list! For this feature you need to find the insertion point and then add the node at that point and NOT change ordering of the other elements.

(Class Manager method - to be executed when the 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 value until either a valid genre 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).

(Class Manager method - to be executed 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 stars until either a legitimate value is entered or the person enters a negative value (to signify that they wish to cancel this option).

(Class Manager method) (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 4th movie while it waits for the user to 'Hit enter to continue'. The output must be displayed in a neat and legible format. (See the above 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).

(Class Manager method) (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).

(Class Manager method) (R)emove a movie from the list: You can implement one of two versions of this feature (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.


The simple version will just remove the last node from the list.


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, an appropriate status message should be displayed if no matches were found.

(Class Manager method) (O)pposite order display: Invoking this method will recursively display the list in reverse order (last movie display first, second last movie displayed second...the first movie is displayed last). This method should only display the list in reverse order but it should NOT change the actual order of the nodes in the list (i.e., after calling this method the movie that was first in the list should still be first in the list etc.) (JT's hint: some of you may find that this last feature is significantly harder than the other features so you might want to work on this one last.) An appropriate status message should be displayed if the list is empty.
Using pre-written Java code
Aside from common sense operators and operations such as those for input/output, unless you are told otherwise, you will need to write your own code and cannot use other pre-written Java classes or operators. Obviously you should not use Java classes that implement a linked list but you can use interfaces that specify a design if you wish.

Marking
To help you ensure that you haven't missed anything here is a [marking checklist]

Points to keep in mind:
Due time: All assignments are due at 4 PM on the due dates listed on the course web page. Late assignments or components of assignments will not be accepted for marking without approval for an extension beforehand. What you have submitted in D2L as of the due date is what will be marked.
Extensions may be granted for reasonable cases by the course instructor with the receipt of the appropriate documentation (e.g., a doctor's note). Typical examples of reasonable cases for an extension include: illness or a death in the family. Cases where extensions will not be granted include situations that are typical of student life: having multiple due dates, work commitments etc. Tutorial instructors (TA's) will not be able to provide extension on their own and must receive permission from the course instructor first. (Note: Forgetting to hand your assignment or a component of your assignment in does not constitute a sufficient reason for handing your assignment late).
Method of submission: You are to submit your assignment using D2L [help link]. Make sure that you [check the contents of your submitted files] (e.g., is the file okay or was it corrupted, is it the correct version etc.). It's your responsibility to do this! (Make sure that your submit your assignment with enough time before it comes due for you to do a check).
Identifying information: All assignments should include contact information (full name and student ID number) at the very top of your program in the class where the 'main()' function/method resides.
Collaboration: Assignments must reflect individual work, group work is not allowed in this class nor can you copy the work of others. For more detailed information as to what constitutes academic misconduct (i.e., cheating) for this course please read the following [link].
Execution: programs must run on the computer science network. If you write you code in the lab and work remotely using a remote login program such as Putty or SSH. If you choose to install Java on your own computer then it is your responsibility to ensure that your program will run properly here. It's not recommended that you use an IDE for writing your programs but if you use one then make sure that you submit your program in the form of individual text ".java" files (one for each class that you define).
Source code: in order to get any credit for your work you must submit all relevant dot-java files for the assignment (e.g., Driver.java). If you only submit your byte code files (e.g. Driver.class) then you will not be awarded any credit.
D2L configuration for this course
You can (and really should) submit work as many times as you wish before the due date
D2L will only retain whatever files that you submitted the last time that you uploaded to D2L, previous files will not be retained (e.g. if you submit files: A.java, B.java, C.jpg the first time and then you submit A.java the second time then D2L will only have one file stored: A.java. That means that you should submit every file associated with the assignment each time that you want to submit something regardless of how many of those files were actually changed since the last submission.

More products