#include "first_interface.h" class MediaPlayer { public: MediaPlayer(){} virtual ~MediaPlayer(){} virtual void play(string audioType, string fileName) = 0; }; class MediaAdapter: public MediaPlayer { public: MediaAdapter(string audioType) { if (audioType == "vlc") { player = new VlcPlayer(); } else if(audioType == "mp4") { player = new Mp4Player(); } else { player = nullptr; } } void play(string audioType, string fileName) { if (audioType == "vlc") { player->playVlc(fileName); } else if(audioType == "mp4") { player->playMp4(fileName); } } public: AdvancedMediaPlayer *player; }; class AudioPlayer: public MediaPlayer { public: void play(string audioType, string fileName) { if (audioType == "mp3") { cout << "Playing mp3 file. Name: " + fileName << endl; } else if(audioType == "mp4" || audioType == "vlc") { MediaAdapter * adapter = new MediaAdapter(audioType); adapter->play(audioType, fileName); } else { cout << "Invalid media. " + audioType + " format not supported"; } } };