Improved comments for decorator example.
This commit is contained in:
parent
9a75cb11c3
commit
10d4e3cadd
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Interface for the hostile enemies.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface Hostile {
|
public interface Hostile {
|
||||||
|
|
||||||
void attack();
|
void attack();
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SmartTroll is a decorator for Hostile objects.
|
||||||
|
* The calls to the Hostile interface are intercepted
|
||||||
|
* and decorated. Finally the calls are delegated
|
||||||
|
* to the decorated Hostile object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class SmartTroll implements Hostile {
|
public class SmartTroll implements Hostile {
|
||||||
|
|
||||||
private Hostile decorated;
|
private Hostile decorated;
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Troll implements Hostile interface directly.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Troll implements Hostile {
|
public class Troll implements Hostile {
|
||||||
|
|
||||||
public void attack() {
|
public void attack() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user