CPSC-115 Fall 2008
Lab 10
November 4/5, 2008
Professor Heidi Ellis

Be sure that you hand in the printouts of your work before leaving!!!

Objectives:

In this lab, you will create a class that represents the Quicklist feature on YouTube. The Quicklist feature allows users to create a list of videos for later viewing. Videos may be added to the list and removed from the list and the list may be searched based on the tag of a video.

Prelab: Write a flowchart algorithm for the removeVideo algorithm. What do you need to do to remove a video from the list? Assume that you have the following videos entered in the array (the lower row simply represents the indices into the array):
123
Sam Spade
4509
10987
4.5
mystery
456
Cam Comedy
5609
9876
3.4
comedy
789
Doni Dancing
7323
9899
1.2
dance
987
Bobby Bin
9989
10900
3.2
comedy
                   
012345
Removing the video with id 456 should result in the following array configuration:
123
Sam Spade
4509
10987
4.5
mystery
789
Doni Dancing
7323
9899
1.2
dance
987
Bobby Bin
9989
10900
3.2
comedy
                             
012345
Your algorithm will not be long, but should provide sufficient detail so that you can write code from the algorithm. Hand the pre-lab into the instructor at the beginning of class.


Pair Programming:
  1. Locate your partner and introduce yourself:
  2. Tuesday Lab   Wednesday Lab
    Kristen AndersonJake Elder     Corazon IrizarryCatherine Doyle
    Nick DraguJeff Young     Chelsea Bainbridge-DonnerJesse Vazquez
        Greg VaughanRyan Ersland
        Jin Feng LiuJohn Wilsterman
  3. Select one person to start as "driver". This person will type at the keyboard for the first 20 mintues.
  4. Proceed through the process of completing the lab as described below. Be very careful to ensure that every item for both programs is completed.
  5. Swap pairs every 20 minutes.
  6. When you are done, be sure to email a copy of the code to the person whose account you are not working in. In other words, make sure that both partners have a copy of the code.

The QuickList Functionality

In this lab, you are to create an application that supports the management of a list of videos similar to a Quicklist on Youtube. The UML diagram of the classes is shown below:
I have provided you with the Video.java class which represents a video such as those posted on Youtube. You are to implement the QuickList class. In order to aid in implementation, I have provided descriptions of each of the methods below: You should also create a QuickListDriver class to test your QuickList class. The main method should do the following:
  1. Create an instance of a QuickList (I created one of size four).
  2. Prompt the user for a file name and read in a series of songs from file into the QuickList object.
  3. Print out the contents of the QuickList.
  4. Create a Video object and add it to the QuickList object.
  5. Print out the contents of the QuickList.
  6. Create another Video object and attempt to add it to the list (beyond the maximum size of the list).
  7. Search for a video that has an ID that you know is contained in the QuickList
  8. object.
  9. Remove a video with an ID that you know is contained in the QuickList object.
  10. Print out the contents of the QuickList.
  11. Attempt to remove a video with an ID that you know does not exist in the QuickList object.
  12. Retrieve a list of videos with a tag that you know exists.
  13. Print that list of videos. You will have to write a loop within your main method to accomplish this.
A sample execution of the main method might appear as below. The output below uses the videos.txt file that contains information for three videos.
Enter name of file that contains the video information: videos.txt

*** Original QuickList:
ID: 123 Author: Sam Spade Length: 75:9 Size: 10.747 MB Rating: 4.5 Tag: mystery
ID: 456 Author: Cam Comedy Length: 93:29 Size: 9.660 MB Rating: 3.4 Tag: comedy
ID: 789 Author: Doni Dancing Length: 122:3 Size: 9.683 MB Rating: 1.2 Tag: dance

*** QuickList after adding a video (888):
ID: 123 Author: Sam Spade Length: 75:9 Size: 10.747 MB Rating: 4.5 Tag: mystery
ID: 456 Author: Cam Comedy Length: 93:29 Size: 9.660 MB Rating: 3.4 Tag: comedy
ID: 789 Author: Doni Dancing Length: 122:3 Size: 9.683 MB Rating: 1.2 Tag: dance
ID: 888 Author: Sally Song Length: 72:23 Size: 96.1019 MB Rating: 3.0 Tag: dance

*** Adding a video that exceeds the size of the list.
Sorry, the list is full with 4 videos. You cannot add another video.

*** Searching for a video. Video 456 found at location: 1

*** Removing video 456.

*** QuickList after removing video with id 456:
ID: 123 Author: Sam Spade Length: 75:9 Size: 10.747 MB Rating: 4.5 Tag: mystery
ID: 789 Author: Doni Dancing Length: 122:3 Size: 9.683 MB Rating: 1.2 Tag: dance
ID: 888 Author: Sally Song Length: 72:23 Size: 96.1019 MB Rating: 3.0 Tag: dance

*** Removing a video that does not exist.
Video was not found.

*** Searching for dance videos.
*** Videos found: 
ID: 789 Author: Doni Dancing Length: 122:3 Size: 9.683 MB Rating: 1.2 Tag: dance
ID: 888 Author: Sally Song Length: 72:23 Size: 96.1019 MB Rating: 3.0 Tag: dance
Note that only the lines that begin with three asterisks are produced by the main method. The rest of the output is produced by methods in the QuickList or Video classes. Test your code carefully to make sure that it operates correctly under a variety of test cases. Your code should have good programming style and follow all Java conventions. Don't forget to use constants where appropriate.

You're done!! Don't forget to log out and hand in your printouts to the professor before you leave!!