# Class DigitalAnnotationDecorator

java.lang.Object
com.university.bookstore.model.Material
com.university.bookstore.decorator.MaterialDecorator
com.university.bookstore.decorator.DigitalAnnotationDecorator

All Implemented Interfaces:
  `Comparable<Material>`

public class DigitalAnnotationDecorator extends MaterialDecorator
Decorator that adds digital annotation functionality to materials. Increases the price and provides annotation management capabilities.

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

  Constructors
  Constructor
  Description
  `DigitalAnnotationDecorator(Material material)`
  Creates a new digital annotation decorator.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addAnnotation(String annotation)`
  Adds an annotation to the material.
  `void`
  `clearAnnotations()`
  Clears all annotations.
  `boolean`
  `equals(Object obj)`
  Materials are equal if they have the same ID.
  `int`
  `getAnnotationCount()`
  Gets the number of annotations.
  `List<String>`
  `getAnnotations()`
  Gets all annotations.
  `double`
  `getDigitalAnnotationCost()`
  Gets the digital annotation cost.
  `String`
  `getDisplayInfo()`
  Abstract method to get a formatted display string.
  `double`
  `getPrice()`
  `boolean`
  `hasAnnotations()`
  Checks if the material has any annotations.
  `int`
  `hashCode()`
  `String`
  `removeAnnotation(int index)`
  Removes an annotation by index.

  ### Methods inherited from class com.university.bookstore.decorator.MaterialDecorator

  `getBaseMaterial, getCreator, getDecoratedMaterial, getDecoratorCount, getDiscountRate, hasDecorators, toString`

  ### Methods inherited from class com.university.bookstore.model.Material

  `compareTo, getDiscountedPrice, getId, getTitle, getType, getYear`

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

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

- ## Constructor Details

  - ### DigitalAnnotationDecorator

    public DigitalAnnotationDecorator(Material material)
    Creates a new digital annotation decorator.
    Parameters:
      `material` - the material to add annotations to

- ## Method Details

  - ### getPrice

    public double getPrice()
    Overrides:
      `getPrice` in class `Material`

  - ### getDisplayInfo

    public String getDisplayInfo()
    Description copied from class: `Material`
    Abstract method to get a formatted display string. Each material type should provide its own formatting.
    Overrides:
      `getDisplayInfo` in class `MaterialDecorator`
    Returns:
      formatted display string

  - ### addAnnotation

    public void addAnnotation(String annotation)
    Adds an annotation to the material.
    Parameters:
      `annotation` - the annotation text
    Throws:
      `IllegalArgumentException` - if annotation is null or empty

  - ### removeAnnotation

    public String removeAnnotation(int index)
    Removes an annotation by index.
    Parameters:
      `index` - the index of the annotation to remove
    Returns:
      the removed annotation
    Throws:
      `IndexOutOfBoundsException` - if index is invalid

  - ### getAnnotations

    public List<String> getAnnotations()
    Gets all annotations.
    Returns:
      unmodifiable list of annotations

  - ### getAnnotationCount

    public int getAnnotationCount()
    Gets the number of annotations.
    Returns:
      the annotation count

  - ### clearAnnotations

    public void clearAnnotations()
    Clears all annotations.

  - ### getDigitalAnnotationCost

    public double getDigitalAnnotationCost()
    Gets the digital annotation cost.
    Returns:
      the annotation cost

  - ### hasAnnotations

    public boolean hasAnnotations()
    Checks if the material has any annotations.
    Returns:
      true if annotations exist

  - ### equals

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

  - ### hashCode

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