Guest User

Untitled

a guest
Sep 27th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.22 KB | None | 0 0
  1. CS 1150 Assignment 5 - NetDiscs
  2. 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.
  3.  
  4. 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)
  5. WARNING
  6. 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.
  7. Requirements
  8. Your application must:
  9. - Provide a brief welcome message and instructions
  10. - Repeat: While the user does not choose “quit”
  11. o Print the menu to the user (in this exact order!)
  12.  1 - Read DVDs from a new DVD file
  13.  2 - Save DVDs to a file
  14.  3 - Display all DVDs
  15.  4 - Add a DVD to the collection
  16.  5 - Remove a DVD by Title
  17.  6 - Remove a DVD by Rank
  18.  7 – Quit
  19. o Ask the user for their menu choice
  20. o Read in their choice
  21. o Perform the appropriate action:
  22.  Read DVDs from a file
  23. • Ask the user for the filename
  24. • Open the file
  25. • Create an empty collection (or empty the collection)
  26. • Read each DVD (one per line)
  27. • Add each DVD to the collection
  28.  Save DVDs to a file
  29. • Ask the user for the filename
  30. • Open the file
  31. • Print the DVD collection to the file
  32.  Display all DVDs
  33. • Print the DVD collection to the screen
  34.  Add a DVD to the collection
  35. • IN ORDER, ask the user for the following, error-check when necessary, repeat until a valid value is received
  36. o Title
  37. o Rank – must be a positive number
  38. o Year – must be greater than 1900
  39. o Box Office Sales – must be a positive number
  40.  Remove a DVD by Title
  41. • Ask the user for the title
  42. • Remove the DVD from the collection
  43.  Remove a DVD by Rank
  44. • Ask the user for the rank – must be a positive number
  45. • Remove the DVD from the collection
  46.  Quit
  47. • Display a “quitting” message
  48. Assumptions
  49. - You may assume that the original DVD file I use to test your application will be properly formatted
  50. - You may assume that the correct TYPE of data will be entered by the user, but not necessarily valid values.
  51. - You may assume that the ranks listed in the file are unique but they may not be sequential or may not start at 1.
  52. - You may assume that there are 50 or FEWER DVDS in the file.
  53. Design
  54. - You must use 3 classes for this assignment: DVD, DVDCollection, and Main
  55. - You may add anything you need to these three classes, but you MUST at least include the following data and methods.
  56.  
  57. - DVD Class
  58. o Represents a single DVD
  59. o Data:
  60.  Title – string that represents the title of the movie
  61.  Rank – unique id that describes the “ranking” of this movie in terms of box office sales (start at 1)
  62.  Year – year this movie was released (after 1900)
  63.  Box Office Sales – total box office sales (> 0)
  64. - DVDCollection Class
  65. o Represents a collection of DVDs using an array
  66. o Data:
  67.  dvds – an array of DVDs, size 50
  68. o Methods
  69.  Constructor
  70. • Initializes the collection to 50 DVDs
  71.  addDVD
  72. • 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.
  73. • Parameters:
  74. o DVD – a single DVD to add
  75. • Return values:
  76. o True – if the DVD was successfully added
  77. o False – if the DVD could not be added because the collection is full
  78.  removeDVD (by rank)
  79. • Removes a single DVD by rank – finds the DVD with a rank that matches the parameter, removing that DVD
  80. • Parameters:
  81. o Rank – a integer representing the rank
  82. • Return values:
  83. o True – if the DVD was successfully removed
  84. o False – if the DVD could not be found
  85.  removeDVD (by title)
  86. • 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
  87. • Parameters:
  88. o Title – a String representing the title of the DVD
  89. • Return values:
  90. o True – if the DVD was successfully removed
  91. o False – if the DVD could not be found
  92.  toString
  93. • Returns a String that represents the entire collection (Hint: use DVD’s toString method!)
  94. - Main Class
  95. o The Driver of your application – this class handles displaying the menu, responding to the user, and displaying error messages
  96. o
  97. 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!)
  98. o Methods:
  99.  readFromFile
  100. • Retrieves the filename from the user
  101. • Opens the file
  102. • Creates a new collection
  103. • Reads each DVD from the file
  104. • Adds each DVD to the Collection
  105.  writeToFile
  106. • Retrieves the filename from the user
  107. • Opens the file
  108. • Writes each DVD to the file
  109.  addDVD
  110. • Ask the user (in order) for:
  111. o Title
  112. o Rank (must be > 0)
  113. o Year (must be > 1900)
  114. o Box Office Sales (must be > 0)
  115. • Print error message if DVD could not be added
  116.  removeByTitle
  117. • Ask the user for the title
  118. • Remove the DVD from the collection
  119. • Print error message if DVD could not be removed
  120.  removeByRank
  121. • Ask the user for the rank
  122. • Remove the DVD from the collection
  123. • Print error message if the DVD could not be removed
  124.  
  125. Example output:
  126. *************************************
  127. ---------------------------------------------
  128. Please make a selection...
  129. 1 - Read DVDs from a new DVD file
  130. 2 - Save DVDs to a file
  131. 3 - Display all DVDs
  132. 4 - Add a DVD to the collection
  133. 5 - Remove a DVD by Title
  134. 6 - Remove a DVD by Rank
  135. 7 - Quit
  136. ---------------------------------------------
  137. 1
  138. What file would you like to open?
  139. dvds_short.txt
  140. ---------------------------------------------
  141. Please make a selection...
  142. 1 - Read DVDs from a new DVD file
  143. 2 - Save DVDs to a file
  144. 3 - Display all DVDs
  145. 4 - Add a DVD to the collection
  146. 5 - Remove a DVD by Title
  147. 6 - Remove a DVD by Rank
  148. 7 - Quit
  149. ---------------------------------------------
  150. 3
  151. 6. E.T.: The Extra-Terrestrial (1982) $434949459
  152. 7. Star Wars: Episode I - The Phantom Menace (1999) $431065444
  153. 8. Pirates of the Caribbean: Dead Man's Chest (2006) $423032628
  154. 9. Toy Story 3 (2010) $414638013
  155. 10. Spider-Man (2002) $403706375
  156. 11. Transformers: Revenge of the Fallen (2009) $402076689
  157.  
  158. ---------------------------------------------
  159. Please make a selection...
  160. 1 - Read DVDs from a new DVD file
  161. 2 - Save DVDs to a file
  162. 3 - Display all DVDs
  163. 4 - Add a DVD to the collection
  164. 5 - Remove a DVD by Title
  165. 6 - Remove a DVD by Rank
  166. 7 - Quit
  167. ---------------------------------------------
  168. 4
  169. What is the DVD's title?
  170. Avatar
  171. What is the DVD's rank?
  172. 1
  173. What is the DVD's year?
  174. 2009
  175. What is the DVD's box office sales?
  176. 760505847
  177. ---------------------------------------------
  178. Please make a selection...
  179. 1 - Read DVDs from a new DVD file
  180. 2 - Save DVDs to a file
  181. 3 - Display all DVDs
  182. 4 - Add a DVD to the collection
  183. 5 - Remove a DVD by Title
  184. 6 - Remove a DVD by Rank
  185. 7 - Quit
  186. ---------------------------------------------
  187. 3
  188. 6. E.T.: The Extra-Terrestrial (1982) $434949459
  189. 7. Star Wars: Episode I - The Phantom Menace (1999) $431065444
  190. 8. Pirates of the Caribbean: Dead Man's Chest (2006) $423032628
  191. 9. Toy Story 3 (2010) $414638013
  192. 10. Spider-Man (2002) $403706375
  193. 11. Transformers: Revenge of the Fallen (2009) $402076689
  194. 1. Avatar (2009) $760505847
  195.  
  196. ---------------------------------------------
  197. Please make a selection...
  198. 1 - Read DVDs from a new DVD file
  199. 2 - Save DVDs to a file
  200. 3 - Display all DVDs
  201. 4 - Add a DVD to the collection
  202. 5 - Remove a DVD by Title
  203. 6 - Remove a DVD by Rank
  204. 7 - Quit
  205. ---------------------------------------------
  206. 5
  207. What title would you like to remove?
  208. Toy Story 3
  209. ---------------------------------------------
  210. Please make a selection...
  211. 1 - Read DVDs from a new DVD file
  212. 2 - Save DVDs to a file
  213. 3 - Display all DVDs
  214. 4 - Add a DVD to the collection
  215. 5 - Remove a DVD by Title
  216. 6 - Remove a DVD by Rank
  217. 7 - Quit
  218. ---------------------------------------------
  219. 3
  220. 6. E.T.: The Extra-Terrestrial (1982) $434949459
  221. 7. Star Wars: Episode I - The Phantom Menace (1999) $431065444
  222. 8. Pirates of the Caribbean: Dead Man's Chest (2006) $423032628
  223. 10. Spider-Man (2002) $403706375
  224. 11. Transformers: Revenge of the Fallen (2009) $402076689
  225. 1. Avatar (2009) $760505847
  226.  
  227. ---------------------------------------------
  228. Please make a selection...
  229. 1 - Read DVDs from a new DVD file
  230. 2 - Save DVDs to a file
  231. 3 - Display all DVDs
  232. 4 - Add a DVD to the collection
  233. 5 - Remove a DVD by Title
  234. 6 - Remove a DVD by Rank
  235. 7 - Quit
  236. ---------------------------------------------
  237. 6
  238. What rank would you like to remove?
  239. 8
  240. ---------------------------------------------
  241. Please make a selection...
  242. 1 - Read DVDs from a new DVD file
  243. 2 - Save DVDs to a file
  244. 3 - Display all DVDs
  245. 4 - Add a DVD to the collection
  246. 5 - Remove a DVD by Title
  247. 6 - Remove a DVD by Rank
  248. 7 - Quit
  249. ---------------------------------------------
  250. 3
  251. 6. E.T.: The Extra-Terrestrial (1982) $434949459
  252. 7. Star Wars: Episode I - The Phantom Menace (1999) $431065444
  253. 10. Spider-Man (2002) $403706375
  254. 11. Transformers: Revenge of the Fallen (2009) $402076689
  255. 1. Avatar (2009) $760505847
  256.  
  257. ---------------------------------------------
  258. Please make a selection...
  259. 1 - Read DVDs from a new DVD file
  260. 2 - Save DVDs to a file
  261. 3 - Display all DVDs
  262. 4 - Add a DVD to the collection
  263. 5 - Remove a DVD by Title
  264. 6 - Remove a DVD by Rank
  265. 7 - Quit
  266. ---------------------------------------------
  267. 2
  268. What file would you like to open?
  269. dvds_out.txt
  270. ---------------------------------------------
  271. Please make a selection...
  272. 1 - Read DVDs from a new DVD file
  273. 2 - Save DVDs to a file
  274. 3 - Display all DVDs
  275. 4 - Add a DVD to the collection
  276. 5 - Remove a DVD by Title
  277. 6 - Remove a DVD by Rank
  278. 7 - Quit
  279. ---------------------------------------------
  280. 8
  281. Incorrect menu choice, try again!
  282. ---------------------------------------------
  283. Please make a selection...
  284. 1 - Read DVDs from a new DVD file
  285. 2 - Save DVDs to a file
  286. 3 - Display all DVDs
  287. 4 - Add a DVD to the collection
  288. 5 - Remove a DVD by Title
  289. 6 - Remove a DVD by Rank
  290. 7 - Quit
  291. ---------------------------------------------
  292. 7
  293. Thank you, come again!
  294. *************************************
  295. Extra Credit – Sorting your Collection (10 points)
  296. 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.
  297. Deliverables
  298. You are required to turn in the following:
  299. - Hard-copy of
  300. o Grading Criteria sheet
  301. o Code
  302. - Electronic-copy of
  303. o Zip your entire project into a single archived file named A5.zip
  304.  All code, Project settings, folders, etc.
  305.  Submit your .zip file to the appropriate Blackboard assignment
Advertisement
Add Comment
Please, Sign In to add comment