Class GiftWrappingDecorator

All Implemented Interfaces:
Comparable<Material>

public class GiftWrappingDecorator extends MaterialDecorator
Decorator that adds gift wrapping functionality to materials. Increases the price and provides gift wrapping information.
Since:
2024-09-15
Version:
3.0
Author:
Navid Mohaghegh
  • Constructor Details

    • GiftWrappingDecorator

      public GiftWrappingDecorator(Material material, String wrappingStyle)
      Creates a new gift wrapping decorator.
      Parameters:
      material - the material to wrap
      wrappingStyle - the style of gift wrapping
      Throws:
      IllegalArgumentException - if wrappingStyle is null or empty
  • Method Details

    • getPrice

      public double getPrice()
      Overrides:
      getPrice in class Material
    • getDisplayInfo

      public String getDisplayInfo()
      Description copied from class: Material
      Abstract method to get a formatted display string. Each material type should provide its own formatting.
      Overrides:
      getDisplayInfo in class MaterialDecorator
      Returns:
      formatted display string
    • getWrappingStyle

      public String getWrappingStyle()
      Gets the wrapping style.
      Returns:
      the wrapping style
    • getGiftWrappingCost

      public double getGiftWrappingCost()
      Gets the gift wrapping cost.
      Returns:
      the gift wrapping cost
    • equals

      public boolean equals(Object obj)
      Description copied from class: Material
      Materials are equal if they have the same ID.
      Overrides:
      equals in class MaterialDecorator
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class MaterialDecorator