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.
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.
(C) 1997 Phil Burk and Nick Didkovsky, All Rights Reserved
JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.