mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-17 04:59:21 +00:00
Refactored Event Queue (#806)
* 1) Test cases were not stopping AudioService before ending test case 2) Changed Audio to be a good singleton, previously because of Audio being bad singleton, test cases which were using static methods could have caused intermittent failures. 3) Made some other refactorings as well * Removed sonar issue and converted Audio to eager singleton for simplicity * Updated class diagram PNG
This commit is contained in:
committed by
Ilkka Seppälä
parent
922fd62da6
commit
25ed7c09c5
@@ -47,13 +47,15 @@ public class App {
|
||||
* @throws IOException when there is a problem with the audio file loading
|
||||
* @throws UnsupportedAudioFileException when the loaded audio file is unsupported
|
||||
*/
|
||||
public static void main(String[] args) throws UnsupportedAudioFileException, IOException {
|
||||
Audio.playSound(Audio.getAudioStream("./etc/Bass-Drum-1.wav"), -10.0f);
|
||||
Audio.playSound(Audio.getAudioStream("./etc/Closed-Hi-Hat-1.wav"), -8.0f);
|
||||
public static void main(String[] args) throws UnsupportedAudioFileException, IOException, InterruptedException {
|
||||
Audio audio = Audio.getInstance();
|
||||
audio.playSound(audio.getAudioStream("./etc/Bass-Drum-1.wav"), -10.0f);
|
||||
audio.playSound(audio.getAudioStream("./etc/Closed-Hi-Hat-1.wav"), -8.0f);
|
||||
|
||||
System.out.println("Press Enter key to stop the program...");
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
br.read();
|
||||
Audio.stopService();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
|
||||
br.read();
|
||||
}
|
||||
audio.stopService();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user