Class MaterialDirector

java.lang.Object
com.university.bookstore.builder.MaterialDirector

public class MaterialDirector extends Object
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 Details

    • MaterialDirector

      public MaterialDirector(EBookBuilder eBookBuilder, MaterialBundleBuilder bundleBuilder)
      Constructs a MaterialDirector with the specified builders.
      Parameters:
      eBookBuilder - the EBook builder
      bundleBuilder - the MaterialBundle builder
  • Method Details

    • buildPremiumEBook

      public Material buildPremiumEBook(String id, String title, String author, double price)
      Constructs a premium EBook with all features enabled.
      Parameters:
      id - the EBook ID
      title - the EBook title
      author - the EBook author
      price - the EBook price
      Returns:
      a premium EBook
    • buildBasicEBook

      public Material buildBasicEBook(String id, String title, String author, double price)
      Constructs a basic EBook with minimal features.
      Parameters:
      id - the EBook ID
      title - the EBook title
      author - the EBook author
      price - the EBook price
      Returns:
      a basic EBook
    • buildStudentEBook

      public Material buildStudentEBook(String id, String title, String author, double price)
      Constructs a student EBook with educational features.
      Parameters:
      id - the EBook ID
      title - the EBook title
      author - the EBook author
      price - the EBook price
      Returns:
      a student EBook
    • buildTextbookBundle

      public MaterialBundle buildTextbookBundle(String bundleName, List<Material> materials)
      Constructs a textbook bundle with a 20% discount.
      Parameters:
      bundleName - the bundle name
      materials - the materials to include in the bundle
      Returns:
      a textbook bundle
    • buildCourseBundle

      public MaterialBundle buildCourseBundle(String bundleName, List<Material> materials)
      Constructs a course bundle with a 25% discount.
      Parameters:
      bundleName - the bundle name
      materials - the materials to include in the bundle
      Returns:
      a course bundle
    • buildPremiumBundle

      public MaterialBundle buildPremiumBundle(String bundleName, List<Material> materials)
      Constructs a premium bundle with a 30% discount.
      Parameters:
      bundleName - the bundle name
      materials - the materials to include in the bundle
      Returns:
      a premium bundle
    • buildStarterBundle

      public MaterialBundle buildStarterBundle(String bundleName, List<Material> materials)
      Constructs a starter bundle with a 10% discount.
      Parameters:
      bundleName - the bundle name
      materials - 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 name
      bundles - the bundles to include
      discount - 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 name
      materials - the materials to include
      discount - the discount rate
      Returns:
      a custom bundle
    • getEBookBuilder

      public EBookBuilder getEBookBuilder()
      Gets the EBook builder for custom configurations.
      Returns:
      the EBook builder
    • getBundleBuilder

      public MaterialBundleBuilder getBundleBuilder()
      Gets the MaterialBundle builder for custom configurations.
      Returns:
      the MaterialBundle builder
    • createEBookBuilder

      public EBookBuilder createEBookBuilder()
      Creates a new EBook builder instance.
      Returns:
      a new EBook builder
    • createBundleBuilder

      public MaterialBundleBuilder createBundleBuilder()
      Creates a new MaterialBundle builder instance.
      Returns:
      a new MaterialBundle builder