Class GiftWrappingDecorator
java.lang.Object
com.university.bookstore.model.Material
com.university.bookstore.decorator.MaterialDecorator
com.university.bookstore.decorator.GiftWrappingDecorator
- All Implemented Interfaces:
Comparable<Material>
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
-
Nested Class Summary
Nested classes/interfaces inherited from class com.university.bookstore.model.Material
Material.MaterialType -
Constructor Summary
ConstructorsConstructorDescriptionGiftWrappingDecorator(Material material, String wrappingStyle) Creates a new gift wrapping decorator. -
Method Summary
Methods inherited from class com.university.bookstore.decorator.MaterialDecorator
getBaseMaterial, getCreator, getDecoratedMaterial, getDecoratorCount, getDiscountRate, hasDecorators, toString
-
Constructor Details
-
GiftWrappingDecorator
Creates a new gift wrapping decorator.- Parameters:
material- the material to wrapwrappingStyle- the style of gift wrapping- Throws:
IllegalArgumentException- if wrappingStyle is null or empty
-
-
Method Details
-
getPrice
-
getDisplayInfo
Description copied from class:MaterialAbstract method to get a formatted display string. Each material type should provide its own formatting.- Overrides:
getDisplayInfoin classMaterialDecorator- Returns:
- formatted display string
-
getWrappingStyle
-
getGiftWrappingCost
public double getGiftWrappingCost()Gets the gift wrapping cost.- Returns:
- the gift wrapping cost
-
equals
Description copied from class:MaterialMaterials are equal if they have the same ID.- Overrides:
equalsin classMaterialDecorator
-
hashCode
public int hashCode()- Overrides:
hashCodein classMaterialDecorator
-