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.

We define a PlayableProvider class with a static array of Playables, and a public static getRandomPlayable() method.

The source code here includes three classes:
1) the applet class itself,
2) the PlayableProvider class, and
3) the SmarterJob class.

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

You have seen two ways of providing custom functionality to MusicJob: subclassing and overriding, versus plugging in Playable at runtime.
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.