The goal of this lab is to show you how you can add musical and sound effects to your game.
The library javalib.soundworld.jar supports the design of the interactive games using imperative style (mutation) with the additional support for playing MIDI tunes. The sounds are specifies as notes to be played on the given instruments as the onTick and onKeyEvent requests are processed. In the case of onTick method, you also specify the duration (how many ticks should a sound be played.) The sounds initiated by the onKeyEvent method play while the corresponding key is pressed.
The tests for the methods with effects are even more difficult. The sample program illustrates how you can test that the program is playing the desired sounds, but this is a truly difficult task. In your work, do the best you can, but we will not require a complete code coverage for testing that the correct sounds are played.
The sample program files:
The file that contains the images of the family used in our sample code family.png.
The complete game written in the functional style TickyTackSong.java.
The javalib-1.0.3.jar jar file
Build a project, import into it the given source code and the image. Add to your project the downloaded jar file and run the game.
Read the code to see how the sound is generated. The complete documentation with samples and explanation can be found at the javalib worlds web pages.