|
Method Name: GetCDByCDID()
|
Class Name: CDList
|
ID:
|
|
Clients (Consumers):
This method will mostly be called by a user interface module in response to an end user wanting to select and display more information for only one CD from the current list of CDs.
The current list of CDs is populated and maintained by a CDList object, and this method is one of the methods of the CDList class.
So the user interface layer module would call this method on a CDList object (called myCDList below), passing in the ID of the selected CD (value of 2 below) like this:
CD myCD = myCDList.GetCDByCDID(2);
|
|
Associated Use Cases:
Place Order
|
|
Description of Responsibilities:
This method searches the current list of CDs that the end user is working with and returns a CD whose ID matches the argument to the method. Otherwise, the method will return NULL (no CD with this ID).
|
|
Arguments Received:
int id
The ID of the selected CD to search for and return
|
|
Type of Value Returned:
A CD object or null (if no object is found)
Definition of the CD class follows (in Java):
class CD
{
public CD(int id, String title, String category)
{
this.CDID = id;
this.CDTitle = title;
this.CDCategory = category;
}
public int CDID;
public String CDTitle;
public String CDCategory;
}
|
|
Pre-Conditions:
1. The CDList object must be populated with a number of CD to select from by CDID. The object could be populated from records in the database, data from a file, or from memory before the method is called.
2. For testing purposes, it was decided that the CDList object will be populated with a number of CD in the constructor method of the CDList class. Thus the right sequence of calling this method is:
CDList myCDList = new CDList();
CD myCD = myCDList.GetCDByCDID(2);
|
|
Post-Conditions:
1. The method either returns a CD matching the CDID provided or returns null if no CD was found matching the provided CDID.
|