# Class Material

java.lang.Object
com.university.bookstore.model.Material

All Implemented Interfaces:
  `Comparable<Material>`

Direct Known Subclasses:
  `AudioBook`, `EBook`, `Magazine`, `MaterialDecorator`, `PrintedBook`, `VideoMaterial`

public abstract class Material extends Object implements Comparable<Material>
Abstract base class representing any material in the store inventory. Demonstrates abstraction and inheritance in OOP design.

This class provides common properties and behavior for all materials including books, magazines, audio, and video content.

Since:
  2024-09-15
Version:
  2.0
Author:
  Navid Mohaghegh

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `Material.MaterialType`
  Enumeration of material types for polymorphic behavior.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compareTo(Material other)`
  Compares materials by title for natural ordering.
  `boolean`
  `equals(Object obj)`
  Materials are equal if they have the same ID.
  `abstract String`
  `getCreator()`
  Abstract method to get the creator/author/artist of the material.
  `final double`
  `getDiscountedPrice()`
  Template method for calculating discounted price.
  `double`
  `getDiscountRate()`
  Hook method for discount rate.
  `abstract String`
  `getDisplayInfo()`
  Abstract method to get a formatted display string.
  `String`
  `getId()`
  `double`
  `getPrice()`
  `String`
  `getTitle()`
  `Material.MaterialType`
  `getType()`
  `int`
  `getYear()`
  `int`
  `hashCode()`
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Method Details

  - ### getCreator

    public abstract String getCreator()
    Abstract method to get the creator/author/artist of the material. Implementation varies by material type.
    Returns:
      the creator's name

  - ### getDisplayInfo

    public abstract String getDisplayInfo()
    Abstract method to get a formatted display string. Each material type should provide its own formatting.
    Returns:
      formatted display string

  - ### getDiscountedPrice

    public final double getDiscountedPrice()
    Template method for calculating discounted price. Subclasses can override getDiscountRate() to customize.
    Returns:
      discounted price

  - ### getDiscountRate

    public double getDiscountRate()
    Hook method for discount rate. Default is no discount. Subclasses can override to provide type-specific discounts.
    Returns:
      discount rate between 0.0 and 1.0

  - ### getId

    public String getId()

  - ### getTitle

    public String getTitle()

  - ### getPrice

    public double getPrice()

  - ### getYear

    public int getYear()

  - ### getType

    public Material.MaterialType getType()

  - ### compareTo

    public int compareTo(Material other)
    Compares materials by title for natural ordering.
    Specified by:
      `compareTo` in interface `Comparable<Material>`

  - ### equals

    public boolean equals(Object obj)
    Materials are equal if they have the same ID.
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`