From 96311a1ff4b96ff29963464643d3656f59e5ac72 Mon Sep 17 00:00:00 2001 From: Hammy Date: Wed, 23 Dec 2020 13:20:12 +0000 Subject: [PATCH] Use local variable --- Design Patterns/src/adapter/media/player/AudioPlayer.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Design Patterns/src/adapter/media/player/AudioPlayer.java b/Design Patterns/src/adapter/media/player/AudioPlayer.java index 1bb97c2..f4b01d4 100644 --- a/Design Patterns/src/adapter/media/player/AudioPlayer.java +++ b/Design Patterns/src/adapter/media/player/AudioPlayer.java @@ -2,15 +2,13 @@ package adapter.media.player; public class AudioPlayer implements MediaPlayer { - private MediaAdapter mediaAdapter; - @Override public void play(String audioType, String fileName) { if (audioType.equalsIgnoreCase("mp3")) { System.out.println("Playing MP3 File | Name: " + fileName); } else if (audioType.equalsIgnoreCase("mp4") || audioType.equalsIgnoreCase("vlc")) { - mediaAdapter = new MediaAdapter(audioType); + MediaAdapter mediaAdapter = new MediaAdapter(audioType); mediaAdapter.play(audioType, fileName); } else { System.out.printf("Media Format '%s' Not Recognised!", audioType);