mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 04:16:14 +00:00
added adapter sample
This commit is contained in:
1 parent
ec8d730113
commit
13e6589471
5 files changed
+68
No files matched your search
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<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"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.iluwatar</groupId>
|
||||||
|
<artifactId>java-design-patterns</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<groupId>com.iluwatar</groupId>
|
||||||
|
<artifactId>adapter</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>adapter</name>
|
||||||
|
<url>http://maven.apache.org</url>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.iluwatar;
|
||||||
|
|
||||||
|
public class App
|
||||||
|
{
|
||||||
|
public static void main( String[] args )
|
||||||
|
{
|
||||||
|
GnomeEngineerAdapter engineer = new GnomeEngineerAdapter();
|
||||||
|
engineer.flyGoblinGlider();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.iluwatar;
|
||||||
|
|
||||||
|
public class GnomeEngineerAdapter {
|
||||||
|
|
||||||
|
private GoblinGlider glider;
|
||||||
|
|
||||||
|
public GnomeEngineerAdapter() {
|
||||||
|
glider = new GoblinGlider();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void flyGoblinGlider() {
|
||||||
|
glider.attachGlider();
|
||||||
|
glider.gainSpeed();
|
||||||
|
glider.takeOff();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.iluwatar;
|
||||||
|
|
||||||
|
public class GoblinGlider {
|
||||||
|
|
||||||
|
public void attachGlider() {
|
||||||
|
System.out.println("glider attached");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void gainSpeed() {
|
||||||
|
System.out.println("gaining speed");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void takeOff() {
|
||||||
|
System.out.println("lift-off!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user