|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectMusicLibrary
public class MusicLibrary
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 |
---|
public MusicLibrary(java.lang.String fileName) throws java.io.FileNotFoundException
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)
fileName
- a String
representing the name of a file
containing information about Songs
java.io.FileNotFoundException
- if the specified file cannot be located/openedMethod Detail |
---|
public int getSize()
Songs
in this
MusicLibrary.
int
corresponding to the size of this
MusicLibrarypublic void printSongsByArtist(java.lang.String artist)
Songs
in this
MusicLibrary
that are performed by the specified artist.
artist
- a String
representing the name of an artistpublic void printSongsOfGenre(java.lang.String genre)
Songs
in this
MusicLibrary
that are of the specified musical genre.
genre
- a String
representing the musical genrepublic static void main(java.lang.String[] args) throws java.io.FileNotFoundException
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:
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.
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.
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.
args
- an array of Strings
representing the command line arguments
java.io.FileNotFoundException
- if the MusicLibrary
constructor throws
a FileNotFoundException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |