Skip to content

Commit 7e828a5

Browse files
committed
After code for Adapter design pattern
- iphone ear plug adapter example
1 parent c07e771 commit 7e828a5

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

pattern/src/com/premaseem/Client.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ public static void main (String[] args) {
2323

2424
// Ear plug is not able to take google phone sound signal
2525
Integer soundSignals = googlePhone.getSoundOutput();
26-
earPlug.takeSoundInput(soundSignals);
26+
27+
// Created adapter to convert signals expected by client
28+
EarPlugAdapter earPlugAdapter = new EarPlugAdapter();
29+
earPlug.takeSoundInput(earPlugAdapter.convertSoundSignal(soundSignals));
2730

2831
}
2932
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.premaseem;
2+
3+
/*
4+
@author: Aseem Jain
5+
@title: Design Patterns with Java 9
6+
@link: https://premaseem.wordpress.com/category/computers/design-patterns/
7+
*/
8+
public class EarPlugAdapter {
9+
10+
public String convertSoundSignal(Integer soundSignal){
11+
return soundSignal.toString();
12+
}
13+
}

0 commit comments

Comments
 (0)