Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CS 1150 Assignment 5 - NetDiscs
- You have just started a new internship at NetDiscs, an online movie-delivery system that allows you to play ANY movie over the internet – no home delivery, no DVDS, just streaming content. Your first responsibility will be to create a DVD management system that will allow you to store a list of the DVDs you would like to watch. Your application will allow the user to read a DVD collection from a file, Add new movies to the collection, remove movies from the collection, and store the collection to a file.
- Your application will be able to save a list of DVDs to a file and then read that list from that file later – TEST THIS! (I will)
- WARNING
- When you produce output into a .txt file, the “\n” characters that you use are not correctly interpreted by Windows. If you open these files using Notepad, it will look like all the text is on one line – this is not really the case. Try opening your file in another application such as EditPlus or DreamWeaver or directly through Netbeans – you’ll see the line breaks.
- Requirements
- Your application must:
- - Provide a brief welcome message and instructions
- - Repeat: While the user does not choose “quit”
- o Print the menu to the user (in this exact order!)
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 – Quit
- o Ask the user for their menu choice
- o Read in their choice
- o Perform the appropriate action:
- Read DVDs from a file
- • Ask the user for the filename
- • Open the file
- • Create an empty collection (or empty the collection)
- • Read each DVD (one per line)
- • Add each DVD to the collection
- Save DVDs to a file
- • Ask the user for the filename
- • Open the file
- • Print the DVD collection to the file
- Display all DVDs
- • Print the DVD collection to the screen
- Add a DVD to the collection
- • IN ORDER, ask the user for the following, error-check when necessary, repeat until a valid value is received
- o Title
- o Rank – must be a positive number
- o Year – must be greater than 1900
- o Box Office Sales – must be a positive number
- Remove a DVD by Title
- • Ask the user for the title
- • Remove the DVD from the collection
- Remove a DVD by Rank
- • Ask the user for the rank – must be a positive number
- • Remove the DVD from the collection
- Quit
- • Display a “quitting” message
- Assumptions
- - You may assume that the original DVD file I use to test your application will be properly formatted
- - You may assume that the correct TYPE of data will be entered by the user, but not necessarily valid values.
- - You may assume that the ranks listed in the file are unique but they may not be sequential or may not start at 1.
- - You may assume that there are 50 or FEWER DVDS in the file.
- Design
- - You must use 3 classes for this assignment: DVD, DVDCollection, and Main
- - You may add anything you need to these three classes, but you MUST at least include the following data and methods.
- - DVD Class
- o Represents a single DVD
- o Data:
- Title – string that represents the title of the movie
- Rank – unique id that describes the “ranking” of this movie in terms of box office sales (start at 1)
- Year – year this movie was released (after 1900)
- Box Office Sales – total box office sales (> 0)
- - DVDCollection Class
- o Represents a collection of DVDs using an array
- o Data:
- dvds – an array of DVDs, size 50
- o Methods
- Constructor
- • Initializes the collection to 50 DVDs
- addDVD
- • Adds a single DVD to the collection – finds an “empty” slot in the array and puts the DVD there, returning true. If no empty slot can be found (the collection is full), false is returned.
- • Parameters:
- o DVD – a single DVD to add
- • Return values:
- o True – if the DVD was successfully added
- o False – if the DVD could not be added because the collection is full
- removeDVD (by rank)
- • Removes a single DVD by rank – finds the DVD with a rank that matches the parameter, removing that DVD
- • Parameters:
- o Rank – a integer representing the rank
- • Return values:
- o True – if the DVD was successfully removed
- o False – if the DVD could not be found
- removeDVD (by title)
- • Removes a single DVD by title – finds the DVD with a title that matches the parameter – ignore differences in upper or lower-case (but not spelling or punctuation), removing that DVD
- • Parameters:
- o Title – a String representing the title of the DVD
- • Return values:
- o True – if the DVD was successfully removed
- o False – if the DVD could not be found
- toString
- • Returns a String that represents the entire collection (Hint: use DVD’s toString method!)
- - Main Class
- o The Driver of your application – this class handles displaying the menu, responding to the user, and displaying error messages
- o
- o You will need one method to “handle” each of the possible user tasks from the menu (except for printing to the screen, that’s a one-liner!)
- o Methods:
- readFromFile
- • Retrieves the filename from the user
- • Opens the file
- • Creates a new collection
- • Reads each DVD from the file
- • Adds each DVD to the Collection
- writeToFile
- • Retrieves the filename from the user
- • Opens the file
- • Writes each DVD to the file
- addDVD
- • Ask the user (in order) for:
- o Title
- o Rank (must be > 0)
- o Year (must be > 1900)
- o Box Office Sales (must be > 0)
- • Print error message if DVD could not be added
- removeByTitle
- • Ask the user for the title
- • Remove the DVD from the collection
- • Print error message if DVD could not be removed
- removeByRank
- • Ask the user for the rank
- • Remove the DVD from the collection
- • Print error message if the DVD could not be removed
- Example output:
- *************************************
- ---------------------------------------------
- Please make a selection...
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 - Quit
- ---------------------------------------------
- 1
- What file would you like to open?
- dvds_short.txt
- ---------------------------------------------
- Please make a selection...
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 - Quit
- ---------------------------------------------
- 3
- 6. E.T.: The Extra-Terrestrial (1982) $434949459
- 7. Star Wars: Episode I - The Phantom Menace (1999) $431065444
- 8. Pirates of the Caribbean: Dead Man's Chest (2006) $423032628
- 9. Toy Story 3 (2010) $414638013
- 10. Spider-Man (2002) $403706375
- 11. Transformers: Revenge of the Fallen (2009) $402076689
- ---------------------------------------------
- Please make a selection...
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 - Quit
- ---------------------------------------------
- 4
- What is the DVD's title?
- Avatar
- What is the DVD's rank?
- 1
- What is the DVD's year?
- 2009
- What is the DVD's box office sales?
- 760505847
- ---------------------------------------------
- Please make a selection...
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 - Quit
- ---------------------------------------------
- 3
- 6. E.T.: The Extra-Terrestrial (1982) $434949459
- 7. Star Wars: Episode I - The Phantom Menace (1999) $431065444
- 8. Pirates of the Caribbean: Dead Man's Chest (2006) $423032628
- 9. Toy Story 3 (2010) $414638013
- 10. Spider-Man (2002) $403706375
- 11. Transformers: Revenge of the Fallen (2009) $402076689
- 1. Avatar (2009) $760505847
- ---------------------------------------------
- Please make a selection...
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 - Quit
- ---------------------------------------------
- 5
- What title would you like to remove?
- Toy Story 3
- ---------------------------------------------
- Please make a selection...
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 - Quit
- ---------------------------------------------
- 3
- 6. E.T.: The Extra-Terrestrial (1982) $434949459
- 7. Star Wars: Episode I - The Phantom Menace (1999) $431065444
- 8. Pirates of the Caribbean: Dead Man's Chest (2006) $423032628
- 10. Spider-Man (2002) $403706375
- 11. Transformers: Revenge of the Fallen (2009) $402076689
- 1. Avatar (2009) $760505847
- ---------------------------------------------
- Please make a selection...
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 - Quit
- ---------------------------------------------
- 6
- What rank would you like to remove?
- 8
- ---------------------------------------------
- Please make a selection...
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 - Quit
- ---------------------------------------------
- 3
- 6. E.T.: The Extra-Terrestrial (1982) $434949459
- 7. Star Wars: Episode I - The Phantom Menace (1999) $431065444
- 10. Spider-Man (2002) $403706375
- 11. Transformers: Revenge of the Fallen (2009) $402076689
- 1. Avatar (2009) $760505847
- ---------------------------------------------
- Please make a selection...
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 - Quit
- ---------------------------------------------
- 2
- What file would you like to open?
- dvds_out.txt
- ---------------------------------------------
- Please make a selection...
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 - Quit
- ---------------------------------------------
- 8
- Incorrect menu choice, try again!
- ---------------------------------------------
- Please make a selection...
- 1 - Read DVDs from a new DVD file
- 2 - Save DVDs to a file
- 3 - Display all DVDs
- 4 - Add a DVD to the collection
- 5 - Remove a DVD by Title
- 6 - Remove a DVD by Rank
- 7 - Quit
- ---------------------------------------------
- 7
- Thank you, come again!
- *************************************
- Extra Credit – Sorting your Collection (10 points)
- Store the DVD collection sorted by Rank – as new DVDs are added, you will need to move older ones around to “create space” for a new rank.
- Deliverables
- You are required to turn in the following:
- - Hard-copy of
- o Grading Criteria sheet
- o Code
- - Electronic-copy of
- o Zip your entire project into a single archived file named A5.zip
- All code, Project settings, folders, etc.
- Submit your .zip file to the appropriate Blackboard assignment
Advertisement
Add Comment
Please, Sign In to add comment