Class ExpeditedDeliveryDecorator
java.lang.Object
com.university.bookstore.model.Material
com.university.bookstore.decorator.MaterialDecorator
com.university.bookstore.decorator.ExpeditedDeliveryDecorator
- All Implemented Interfaces:
Comparable<Material>
Decorator that adds expedited delivery functionality to materials.
Increases the price and provides delivery time 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
ConstructorsConstructorDescriptionExpeditedDeliveryDecorator(Material material, int deliveryDays) Creates a new expedited delivery decorator. -
Method Summary
Methods inherited from class com.university.bookstore.decorator.MaterialDecorator
getBaseMaterial, getCreator, getDecoratedMaterial, getDecoratorCount, getDiscountRate, hasDecorators, toString
-
Constructor Details
-
ExpeditedDeliveryDecorator
Creates a new expedited delivery decorator.- Parameters:
material- the material to add expedited delivery todeliveryDays- the number of days for delivery (minimum 1)- Throws:
IllegalArgumentException- if deliveryDays is less than 1
-
-
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
-
getDeliveryDays
public int getDeliveryDays()Gets the delivery time in days.- Returns:
- the delivery days
-
getExpeditedDeliveryCost
public double getExpeditedDeliveryCost()Gets the expedited delivery cost.- Returns:
- the expedited delivery 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
-