Skip to content

Commit 4198141

Browse files
committed
Fixed Adapter
1 parent cecdcea commit 4198141

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

src/StructuralPatterns/AdapterDP/RectangularAdapter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
public class RectangularAdapter extends CylindricalSocket {
44
public String adapt(String rectaStem1, String rectaStem2) {
5-
//some conversion logic
65
byte[] cylinStem1 = rectaStem1.getBytes();
76
byte[] cylinStem2 = rectaStem2.getBytes();
8-
//invoke supply on a converted input
9-
return supply(cylinStem1, cylinStem2);
7+
return super.supply(cylinStem1, cylinStem2);
108
}
119
}
1210

src/StructuralPatterns/AdapterDP/RectangularPlug.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ public RectangularPlug(String stem1, String stem2){
88
rectaStem2 = stem2;
99
}
1010
public void getPower() {
11-
//the row below does not work because input
12-
//does not match the supply method of CylindricalSocket:
13-
//String power = new CylindricalSocket().supply(rectaStem1, rectaStem2);
14-
//solution - use the adapter!
1511
RectangularAdapter adapter = new RectangularAdapter();
1612
String power = adapter.adapt(rectaStem1, rectaStem2);
1713
System.out.println(power);

0 commit comments

Comments
 (0)