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

jGuru: The MusicStore Class

 

by jGuru

[Help | API Docs | Short Course| Exercises]

For this exercise you implement the first version of a user-defined data type MusicStore. This class will be used in subsequent exercises as well.

Prerequisites

Skeleton Code

Tasks

  1. Design and implement MusicStore as a public class with one public method, displayHoursOfOperation. This method displays the daily hours of operation to the standard output device (often called stdout or standard out), which is either a command window or an IDE window, depending on your Java environment.

    Check the expected output to determine exactly what to print out.

  2. Design and implement TestMusicStore as a public class with one public static void method main. main performs the following tasks:

    • Creates an instance of MusicStore
    • Invokes the displayHoursOfOperation method to display the daily hours of operation to standard output
    • Terminates the program with exit

  3. Compile the source code for MusicStore and TestMusicStore.

  4. 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:

Store Hours: Daily:  9:00 AM - 21:00 PM

Of course, as the store proprietor, you choose the hours of operation.

Next Exercise

Exercises

Short Course

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