Sun Java Solaris Communities My SDN Account Join SDN
 
Tutorials & Code Camps

jGuru: MusicStore: Adding Titles

 


by jGuru

[Help | API Docs | Short Course| Exercises]

For this exercise you add the capability for managing multiple music titles, that is, storing, retrieving, and displaying titles.

Prerequisites

Skeleton Code

Tasks

  1. Create the user-defined data type MusicTitle with two String instance variables, title and artist, initialized to a "noname"-type of value to enhance debugging. Implement get and set access methods for both instance variables.

  2. Add the instance variable titles of type MusicTitle[] to MusicStore, initialized to null, and then implement the access methods setTitles() and getTitles().

  3. Add a displayMusicTitles() method to MusicStore that traverses the array of titles and displays the title-artist data.

  4. Modify TestMusicStore to test/display the functionality of MusicStore's displayMusicTitles() method.

  5. Compile the source code for MusicStore and TestMusicStore.

  6. Execute TestMusicStore.

Where help exists, the task numbers above are linked to the step-by-step help page.

Solution Source

Demonstration

The output should be similar to the following, either on the command line or in an IDE window:

Title 1:
  Title:  Las Cosas Que Vives
 Artist:  Laura Pausini

Title 2:
  Title:  Luna Nueva
 Artist:  Diego Torres

Exercises

Short Course

Copyright 1996-2000 jGuru.com. All Rights Reserved.