Class MusicLibrary

java.lang.Object
  extended by MusicLibrary

public class MusicLibrary
extends java.lang.Object

An instance of the MusicLibrary class represents a collection of songs.


Constructor Summary
MusicLibrary(java.lang.String fileName)
          Creates a MusicLibrary containing all of the Songs specified in the input file.
 
Method Summary
 int getSize()
          Returns the number of Songs in this MusicLibrary.
static void main(java.lang.String[] args)
          The main method should provide an interactive program that creates a MusicLibrary and queries that MusicLibrary based on input from the user.
 void printSongsByArtist(java.lang.String artist)
          Writes to standard output all Songs in this MusicLibrary that are performed by the specified artist.
 void printSongsOfGenre(java.lang.String genre)
          Writes to standard output all Songs in this MusicLibrary that are of the specified musical genre.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MusicLibrary

public MusicLibrary(java.lang.String fileName)
             throws java.io.FileNotFoundException
Creates a MusicLibrary containing all of the Songs specified in the input file.

An input file consists of three lines of text per song. For each song, the first line corresponds to the song's title, the second line to the artist, and the third line to the genre.

Note: when attempting to create a new File object, e.g.,
new File(fileName)
some versions of Dr. Java have difficultly determining the appropriate folder on your computer in which to look for the file. To rectify this issue, the following invocation
FolderOps.getFolder()
will specify the appropriate folder. Thus, a new File object can be created successfully as follows:
new File(FolderOps.getFolder() + fileName)

Parameters:
fileName - a String representing the name of a file containing information about Songs
Throws:
java.io.FileNotFoundException - if the specified file cannot be located/opened
Method Detail

getSize

public int getSize()
Returns the number of Songs in this MusicLibrary.

Returns:
an int corresponding to the size of this MusicLibrary

printSongsByArtist

public void printSongsByArtist(java.lang.String artist)
Writes to standard output all Songs in this MusicLibrary that are performed by the specified artist.

Parameters:
artist - a String representing the name of an artist

printSongsOfGenre

public void printSongsOfGenre(java.lang.String genre)
Writes to standard output all Songs in this MusicLibrary that are of the specified musical genre.

Parameters:
genre - a String representing the musical genre

main

public static void main(java.lang.String[] args)
                 throws java.io.FileNotFoundException
The main method should provide an interactive program that creates a MusicLibrary and queries that MusicLibrary based on input from the user. The main method should perform the following three tasks:

1. The main method should prompt the user for the name of a file containing information about Songs. A MusicLibrary object should be created based on the file input by the user. The number of songs in the newly created MusicLibrary should be written to standard output.

2. The main method should prompt the user for the name of a performing artist. All songs in the MusicLibrary by that artist should be written to standard out.

3. The main method should prompt the user for the name of a musical genre. All songs in the MusicLibrary of that genre should be written to standard out.

Parameters:
args - an array of Strings representing the command line arguments
Throws:
java.io.FileNotFoundException - if the MusicLibrary constructor throws a FileNotFoundException