Class Decorator

java.lang.Object
Structural.Decorator.Decorator
All Implemented Interfaces:
Component
Direct Known Subclasses:
ConcreteDecoratorA, ConcreteDecoratorB

public abstract class Decorator extends Object implements Component
The Decorator class wraps a Component and adds functionality dynamically.
  • Field Details

    • component

      protected Component component
      The wrapped Component.
  • Constructor Details

    • Decorator

      public Decorator(Component component)
      Constructor accepting a Component to wrap.
      Parameters:
      component - The Component to wrap.
  • Method Details

    • getDescription

      public String getDescription()
      Description copied from interface: Component
      Gets the description of the component.
      Specified by:
      getDescription in interface Component
      Returns:
      A string description.
    • cost

      public double cost()
      Description copied from interface: Component
      Gets the cost of the component.
      Specified by:
      cost in interface Component
      Returns:
      The cost as a double.