diff --git a/adapter/src/main/java/com/iluwatar/adapter/App.java b/adapter/src/main/java/com/iluwatar/adapter/App.java index c33780198..d57cb91e4 100644 --- a/adapter/src/main/java/com/iluwatar/adapter/App.java +++ b/adapter/src/main/java/com/iluwatar/adapter/App.java @@ -1,43 +1,38 @@ package com.iluwatar.adapter; /** - * An adapter helps two incompatible interfaces to work together. This is the - * real world definition for an adapter. Interfaces may be incompatible but the - * inner functionality should suit the need. The Adapter design pattern allows - * otherwise incompatible classes to work together by converting the interface - * of one class into an interface expected by the clients. - * + * An adapter helps two incompatible interfaces to work together. This is the real world definition + * for an adapter. Interfaces may be incompatible but the inner functionality should suit the need. + * The Adapter design pattern allows otherwise incompatible classes to work together by converting + * the interface of one class into an interface expected by the clients. + * *
- * There are two variations of the Adapter pattern: The class adapter implements - * the adaptee's interface whereas the object adapter uses composition to - * contain the adaptee in the adapter object. This example uses the object - * adapter approach. - * + * There are two variations of the Adapter pattern: The class adapter implements the adaptee's + * interface whereas the object adapter uses composition to contain the adaptee in the adapter + * object. This example uses the object adapter approach. + * *
- * The Adapter ({@link BattleFishingBoat}) converts the interface of the adaptee - * class ( {@link FishingBoat}) into a suitable one expected by the client ( - * {@link BattleShip} ). - * + * The Adapter ({@link BattleFishingBoat}) converts the interface of the adaptee class ( + * {@link FishingBoat}) into a suitable one expected by the client ( {@link BattleShip} ). + * *
* The story of this implementation is this.
- * Pirates are coming! we need a {@link BattleShip} to fight! We have a
- * {@link FishingBoat} and our captain. We have no time to make up a new ship!
- * we need to reuse this {@link FishingBoat}. The captain needs a battleship
- * which can fire and move. The spec is in {@link BattleShip}. We will use the
- * Adapter pattern to reuse {@link FishingBoat}.
- *
+ * Pirates are coming! we need a {@link BattleShip} to fight! We have a {@link FishingBoat} and our
+ * captain. We have no time to make up a new ship! we need to reuse this {@link FishingBoat}. The
+ * captain needs a battleship which can fire and move. The spec is in {@link BattleShip}. We will
+ * use the Adapter pattern to reuse {@link FishingBoat}.
+ *
*/
public class App {
- /**
- * Program entry point.
- *
- * @param args
- * command line args
- */
- public static void main(String[] args) {
- Captain captain = new Captain(new BattleFishingBoat());
- captain.move();
- captain.fire();
- }
+ /**
+ * Program entry point.
+ *
+ * @param args command line args
+ */
+ public static void main(String[] args) {
+ Captain captain = new Captain(new BattleFishingBoat());
+ captain.move();
+ captain.fire();
+ }
}
diff --git a/adapter/src/main/java/com/iluwatar/adapter/BattleFishingBoat.java b/adapter/src/main/java/com/iluwatar/adapter/BattleFishingBoat.java
index ffd73de3a..3f573337f 100644
--- a/adapter/src/main/java/com/iluwatar/adapter/BattleFishingBoat.java
+++ b/adapter/src/main/java/com/iluwatar/adapter/BattleFishingBoat.java
@@ -1,13 +1,13 @@
package com.iluwatar.adapter;
/**
- *
+ *
* Adapter class. Adapts the interface of the device ({@link FishingBoat}) into {@link BattleShip}
* interface expected by the client ({@link Captain}).
* In this case we added a new function fire to suit the interface. We are reusing the
* {@link FishingBoat} without changing itself. The Adapter class can just map the functions of the
* Adaptee or add, delete features of the Adaptee.
- *
+ *
*/
public class BattleFishingBoat implements BattleShip {
diff --git a/adapter/src/main/java/com/iluwatar/adapter/BattleShip.java b/adapter/src/main/java/com/iluwatar/adapter/BattleShip.java
index 90b18f758..d4f6036e6 100644
--- a/adapter/src/main/java/com/iluwatar/adapter/BattleShip.java
+++ b/adapter/src/main/java/com/iluwatar/adapter/BattleShip.java
@@ -3,7 +3,7 @@ package com.iluwatar.adapter;
/**
* The interface expected by the client.
* A Battleship can fire and move.
- *
+ *
*/
public interface BattleShip {
diff --git a/adapter/src/main/java/com/iluwatar/adapter/FishingBoat.java b/adapter/src/main/java/com/iluwatar/adapter/FishingBoat.java
index d2f9dae25..509bb8cdb 100644
--- a/adapter/src/main/java/com/iluwatar/adapter/FishingBoat.java
+++ b/adapter/src/main/java/com/iluwatar/adapter/FishingBoat.java
@@ -1,9 +1,9 @@
package com.iluwatar.adapter;
/**
- *
+ *
* Device class (adaptee in the pattern). We want to reuse this class
- *
+ *
*/
public class FishingBoat {
diff --git a/adapter/src/test/java/com/iluwatar/adapter/AdapterPatternTest.java b/adapter/src/test/java/com/iluwatar/adapter/AdapterPatternTest.java
index c9a1a9bca..98c7cee2d 100644
--- a/adapter/src/test/java/com/iluwatar/adapter/AdapterPatternTest.java
+++ b/adapter/src/test/java/com/iluwatar/adapter/AdapterPatternTest.java
@@ -15,77 +15,52 @@ import com.iluwatar.adapter.Captain;
import com.iluwatar.adapter.FishingBoat;
/**
- * An adapter helps two incompatible interfaces to work together. This is the
- * real world definition for an adapter. Interfaces may be incompatible but the
- * inner functionality should suit the need. The Adapter design pattern allows
- * otherwise incompatible classes to work together by converting the interface
- * of one class into an interface expected by the clients.
- *
- *
- * There are two variations of the Adapter pattern: The class adapter implements - * the adaptee's interface whereas the object adapter uses composition to - * contain the adaptee in the adapter object. This example uses the object - * adapter approach. - * - *
- * The Adapter ({@link BattleFishingBoat}) converts the interface of the adaptee - * class ( {@link FishingBoat}) into a suitable one expected by the client ( - * {@link BattleShip} ). - * - *
- * The story of this implementation is this.
- * Pirates are coming! we need a {@link BattleShip} to fight! We have a
- * {@link FishingBoat} and our captain. We have no time to make up a new ship!
- * we need to reuse this {@link FishingBoat}. The captain needs a battleship
- * which can fire and move. The spec is in {@link BattleShip}. We will use the
- * Adapter pattern to reuse {@link FishingBoat} which operates properly
+ * Test class
*
*/
public class AdapterPatternTest {
- private Map