15-100:
Introductory/Intermediate Programming
(Section F) |
Fall 2006 |
Assignment: (This assignment is EXTRA CREDIT.) Get the EC-music.zip file. This contains the data files. For this assignment, you are given a fairly hefty assignment and almost no framework. Thus, you will be asked to do a lot more design than you are used to. At the bottom of this, you will find some thoughts/suggestions on how to proceed. You are to consider files that represent the tracks on a CD. The format is as follows: Line 1: Name of CDFurther, you have files that contain lists of CDs in a library. The format is as follows: Each CD is represented on two lines. Line 1: the name of the CD Line 2: the name of the file that contains the track listingMany sample CD files are given to you (and feel free to create you own). Sample library files include library1.txt, library2.txt and library3.txt. Your task:
Suggestions on approach: You will want to build a class to model the items you are dealing with. A class to represent one CD seems reasonable. A class to represent the entire library seems reasonable. A class to represent a song list might be helpful as well. What would the CD class look like? I suspect it will have fields for all of the information that you know about a CD. (The tracks are likely to be an array.) You will probably have accessor methods to get those individual pieces of information. What would an accessor for a particular track look like? Perhaps a method public String getTrack(int n) where n is the track number you want. What mutators would you want? Perhaps one to add a track to the end of the listing. What would the CDLibrary class look like? You are likely to have an array of CDs. You will probably want a method to add a CD to the library. You might want a method "getSongList" that returns a SongList meeting the specifications given. What would the SongList class look like? It will likely have an array of Strings. You will want to be able to display the entire song list, as well as add a new song to it. For instance, for "Random", you might start with an empty SongList, randomly select a song and add it to the list. What would you have in your main method? You will need to get the initial library file from the user and what they want to do with it. Other than interactions with the user and with the files, there should be very little in main.
Handin:
|