@@ -0,0 +1,2299 @@
+import java.io.*;%0Aimport java.net.URL;%0Aimport javax.sound.sampled.*;%0A   %0A/**%0A * This enum encapsulates all the sound effects of a game, so as to separate the sound playing%0A * codes from the game codes.%0A * 1. Define all your sound effect names and the associated wave file.%0A * 2. To play a specific sound, simply invoke SoundEffect.SOUND_NAME.play().%0A * 3. You might optionally invoke the static method SoundEffect.init() to pre-load all the%0A *    sound files, so that the play is not paused while loading the file for the first time.%0A * 4. You can use the static variable SoundEffect.volume to mute the sound.%0A */%0Apublic enum SoundEffect %7B%0A   CHOMP(%22chomp.wav%22);   // explosion%0A%0A   %0A   // Nested class for specifying volume%0A   public static enum Volume %7B%0A      MUTE, LOW, MEDIUM, HIGH%0A   %7D%0A   %0A   public static Volume volume = Volume.LOW;%0A   %0A   // Each sound effect has its own clip, loaded with its own sound file.%0A   private Clip clip;%0A   %0A   // Constructor to construct each element of the enum with its own sound file.%0A   SoundEffect(String soundFileName) %7B%0A      try %7B%0A         // Use URL (instead of File) to read from disk and JAR.%0A         URL url = this.getClass().getClassLoader().getResource(soundFileName);%0A         // Set up an audio input stream piped from the sound file.%0A         AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(url);%0A         // Get a clip resource.%0A         clip = AudioSystem.getClip();%0A         // Open audio clip and load samples from the audio input stream.%0A         clip.open(audioInputStream);%0A      %7D catch (UnsupportedAudioFileException e) %7B%0A         e.printStackTrace();%0A      %7D catch (IOException e) %7B%0A         e.printStackTrace();%0A      %7D catch (LineUnavailableException e) %7B%0A         e.printStackTrace();%0A      %7D%0A   %7D%0A   %0A   // Play or Re-play the sound effect from the beginning, by rewinding.%0A   public void play() %7B%0A      if (volume != Volume.MUTE) %7B%0A         if (clip.isRunning())%0A            clip.stop();   // Stop the player if it is still running%0A         clip.setFramePosition(0); // rewind to the beginning%0A         clip.start();     // Start playing%0A      %7D%0A   %7D%0A   %0A   // Optional static method to pre-load all the sound files.%0A   static void init() %7B%0A      values(); // calls the constructor for all the elements%0A   %7D%0A%7D%0A

Create Soundeffect.java