Class MaterialDirector
java.lang.Object
com.university.bookstore.builder.MaterialDirector
Director class that orchestrates the construction of complex Material objects
using various builders. Demonstrates the Director pattern in conjunction
with the Builder pattern for creating predefined configurations.
- Since:
- 2024-09-15
- Version:
- 3.0
- Author:
- Navid Mohaghegh
-
Constructor Summary
ConstructorsConstructorDescriptionMaterialDirector(EBookBuilder eBookBuilder, MaterialBundleBuilder bundleBuilder) Constructs a MaterialDirector with the specified builders. -
Method Summary
Modifier and TypeMethodDescriptionbuildBasicEBook(String id, String title, String author, double price) Constructs a basic EBook with minimal features.buildCourseBundle(String bundleName, List<Material> materials) Constructs a course bundle with a 25% discount.buildCustomBundle(String bundleName, List<Material> materials, double discount) Constructs a custom bundle with specified parameters.buildNestedBundle(String bundleName, List<MaterialBundle> bundles, double discount) Constructs a nested bundle (bundle containing other bundles).buildPremiumBundle(String bundleName, List<Material> materials) Constructs a premium bundle with a 30% discount.buildPremiumEBook(String id, String title, String author, double price) Constructs a premium EBook with all features enabled.buildStarterBundle(String bundleName, List<Material> materials) Constructs a starter bundle with a 10% discount.buildStudentEBook(String id, String title, String author, double price) Constructs a student EBook with educational features.buildTextbookBundle(String bundleName, List<Material> materials) Constructs a textbook bundle with a 20% discount.Creates a new MaterialBundle builder instance.Creates a new EBook builder instance.Gets the MaterialBundle builder for custom configurations.Gets the EBook builder for custom configurations.
-
Constructor Details
-
MaterialDirector
Constructs a MaterialDirector with the specified builders.- Parameters:
eBookBuilder- the EBook builderbundleBuilder- the MaterialBundle builder
-
-
Method Details
-
buildPremiumEBook
-
buildBasicEBook
-
buildStudentEBook
-
buildTextbookBundle
Constructs a textbook bundle with a 20% discount.- Parameters:
bundleName- the bundle namematerials- the materials to include in the bundle- Returns:
- a textbook bundle
-
buildCourseBundle
Constructs a course bundle with a 25% discount.- Parameters:
bundleName- the bundle namematerials- the materials to include in the bundle- Returns:
- a course bundle
-
buildPremiumBundle
Constructs a premium bundle with a 30% discount.- Parameters:
bundleName- the bundle namematerials- the materials to include in the bundle- Returns:
- a premium bundle
-
buildStarterBundle
Constructs a starter bundle with a 10% discount.- Parameters:
bundleName- the bundle namematerials- the materials to include in the bundle- Returns:
- a starter bundle
-
buildNestedBundle
public MaterialBundle buildNestedBundle(String bundleName, List<MaterialBundle> bundles, double discount) Constructs a nested bundle (bundle containing other bundles).- Parameters:
bundleName- the bundle namebundles- the bundles to includediscount- the discount rate- Returns:
- a nested bundle
-
buildCustomBundle
public MaterialBundle buildCustomBundle(String bundleName, List<Material> materials, double discount) Constructs a custom bundle with specified parameters.- Parameters:
bundleName- the bundle namematerials- the materials to includediscount- the discount rate- Returns:
- a custom bundle
-
getEBookBuilder
Gets the EBook builder for custom configurations.- Returns:
- the EBook builder
-
getBundleBuilder
Gets the MaterialBundle builder for custom configurations.- Returns:
- the MaterialBundle builder
-
createEBookBuilder
Creates a new EBook builder instance.- Returns:
- a new EBook builder
-
createBundleBuilder
Creates a new MaterialBundle builder instance.- Returns:
- a new MaterialBundle builder
-