AudioPlayer can play mp3 format audio files by default. We have a MediaPlayer interface and a concrete class AudioPlayer implementing the MediaPlayer interface. We are demonstrating use of Adapter pattern via following example in which an audio player device can play mp3 files only and wants to use an advanced audio player capable of playing vlc and mp4 files. You plugin the memory card into card reader and card reader into the laptop so that memory card can be read via laptop. ![]() A real life example could be a case of card reader which acts as an adapter between memory card and a laptop. This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces. This type of design pattern comes under structural pattern as this pattern combines the capability of two independent interfaces. ![]() Adapter pattern works as a bridge between two incompatible interfaces.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |