Package Structural.Decorator
Class Decorator
java.lang.Object
Structural.Decorator.Decorator
- All Implemented Interfaces:
Component
- Direct Known Subclasses:
ConcreteDecoratorA,ConcreteDecoratorB
The Decorator class wraps a Component and adds functionality dynamically.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublecost()Gets the cost of the component.Gets the description of the component.
-
Field Details
-
component
The wrapped Component.
-
-
Constructor Details
-
Decorator
Constructor accepting a Component to wrap.- Parameters:
component- The Component to wrap.
-
-
Method Details
-
getDescription
Description copied from interface:ComponentGets the description of the component.- Specified by:
getDescriptionin interfaceComponent- Returns:
- A string description.
-
cost
public double cost()Description copied from interface:ComponentGets the cost of the component.
-