Skip to content

Commit 13e6589

Browse files
committed
added adapter sample
1 parent ec8d730 commit 13e6589

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

adapter/pom.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>com.iluwatar</groupId>
7+
<artifactId>java-design-patterns</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<groupId>com.iluwatar</groupId>
11+
<artifactId>adapter</artifactId>
12+
<version>1.0-SNAPSHOT</version>
13+
<name>adapter</name>
14+
<url>http://maven.apache.org</url>
15+
<dependencies>
16+
<dependency>
17+
<groupId>junit</groupId>
18+
<artifactId>junit</artifactId>
19+
<version>3.8.1</version>
20+
<scope>test</scope>
21+
</dependency>
22+
</dependencies>
23+
</project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.iluwatar;
2+
3+
public class App
4+
{
5+
public static void main( String[] args )
6+
{
7+
GnomeEngineerAdapter engineer = new GnomeEngineerAdapter();
8+
engineer.flyGoblinGlider();
9+
}
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.iluwatar;
2+
3+
public class GnomeEngineerAdapter {
4+
5+
private GoblinGlider glider;
6+
7+
public GnomeEngineerAdapter() {
8+
glider = new GoblinGlider();
9+
}
10+
11+
public void flyGoblinGlider() {
12+
glider.attachGlider();
13+
glider.gainSpeed();
14+
glider.takeOff();
15+
}
16+
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.iluwatar;
2+
3+
public class GoblinGlider {
4+
5+
public void attachGlider() {
6+
System.out.println("glider attached");
7+
}
8+
9+
public void gainSpeed() {
10+
System.out.println("gaining speed");
11+
}
12+
13+
public void takeOff() {
14+
System.out.println("lift-off!");
15+
}
16+
17+
}

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
<module>factory-method</module>
2424
<module>prototype</module>
2525
<module>singleton</module>
26+
<module>adapter</module>
2627
</modules>
2728
</project>

0 commit comments

Comments
 (0)