Fixed code to follow coding conventions

This commit is contained in:
JuhoKang
2015-12-07 10:35:32 +09:00
parent 33b41f872e
commit e2d8079b36
5 changed files with 66 additions and 96 deletions

View File

@ -1,30 +1,26 @@
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.
*
* <p>
* 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.
*
* <p>
* 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} ).
*
* <p>
* The story of this implementation is this. <br>
* 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 {
@ -32,8 +28,7 @@ public class App {
/**
* Program entry point.
*
* @param args
* command line args
* @param args command line args
*/
public static void main(String[] args) {
Captain captain = new Captain(new BattleFishingBoat());

View File

@ -15,30 +15,7 @@ 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.
*
* <p>
* 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.
*
* <p>
* The Adapter ({@link BattleFishingBoat}) converts the interface of the adaptee
* class ( {@link FishingBoat}) into a suitable one expected by the client (
* {@link BattleShip} ).
*
* <p>
* The story of this implementation is this. <br>
* 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 {
@ -50,8 +27,7 @@ public class AdapterPatternTest {
private static final String CAPTAIN_BEAN = "captain";
/**
* This method runs before the test execution and sets the bean objects in
* the beans Map.
* This method runs before the test execution and sets the bean objects in the beans Map.
*/
@Before
public void setup() {
@ -66,11 +42,10 @@ public class AdapterPatternTest {
}
/**
* This test asserts that when we use the move() method on a captain
* bean(client), it is internally calling move method on the battleship
* object. The Adapter ({@link BattleFishingBoat}) converts the interface of
* the target class ( {@link FishingBoat}) into a suitable one expected by
* the client ({@link Captain} ).
* This test asserts that when we use the move() method on a captain bean(client), it is
* internally calling move method on the battleship object. The Adapter ({@link BattleFishingBoat}
* ) converts the interface of the target class ( {@link FishingBoat}) into a suitable one
* expected by the client ({@link Captain} ).
*/
@Test
public void testAdapter() {