JMSL Tutorial: MusicJob

This example shows a MusicJob which changes its own list of RepeatPlayables each time it repeats. The overridden repeat() method simply selects a predefined Playable at random and plugs it into its list of repeatPlayables. Notice that before adding the chosen Playable, it must clear its repeatPlayables, otherwise the list of repeatPlayables would grow by one each time the MusicJob repeats.
Check out the source code, which includes both the applet source and the source for SmartJob.

You need a Java-enabled browser to view this applet.

After examining the source, some of you may have furrowed brows. You've noticed that each instance of SmartJob has an identical array of Playables from which to choose (redundant and inflexible). It would be a better design to have a custom class, separate from SmartJob, whose task it is to provide random Playables to anyone who wants them. We implement this slicker version in the next, and final, MusicJob tutorial.

Previous Tutorial Index Tutorial Contents Next
  (C) 1997 Phil Burk and Nick Didkovsky, All Rights Reserved
  JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.