CDCatalogpublic class CDCatalog extends Object
CDCatalog is a standalone Java class that stores
CDs. It allows addition, retrieval, and listing of CDs. In this
case, it is intended to be used as a web service, although no
special coding considerations were taken with this in mind.
|
Fields Summary |
---|
private Hashtable | catalogThe CDs, by title |
Constructors Summary |
---|
public CDCatalog()Default constructor to initialize storage.
catalog = new Hashtable();
// Seed the catalog
addCD(new CD("Nickel Creek", "Nickel Creek", "Sugar Hill"));
addCD(new CD("Let it Fall", "Sean Watkins", "Sugar Hill"));
addCD(new CD("Aerial Boundaries", "Michael Hedges", "Windham Hill"));
addCD(new CD("Taproot", "Michael Hedges", "Windham Hill"));
|
Methods Summary |
---|
public void | addCD(CD cd)This adds a new {@link CD} to the catalog.
if (cd == null) {
throw new IllegalArgumentException("The CD object cannot be null.");
}
catalog.put(cd.getTitle(), cd);
| public CD | getCD(java.lang.String title)
This will retrieve the {@link CD} with the supplied
title, or null if no such CD is found.
if (title == null) {
throw new IllegalArgumentException("Title cannot be null.");
}
// Return the requested CD
return (CD)catalog.get(title);
| public java.util.Hashtable | list()This returns a listing of all CDs in this catalog.
return catalog;
|
|