mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 20:17:21 +00:00
Improved comments for decorator example.
This commit is contained in:
1 parent
9a75cb11c3
commit
10d4e3cadd
3 files changed
+17
No files matched your search
@@ -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() {
|
||||||
|
|||||||
Reference in new issue
Block a user