# Class EBook

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

All Implemented Interfaces:
  `Media`, `Comparable<Material>`

public class EBook extends Material implements Media
Represents an electronic book (e-book) in the bookstore system. Extends Material and implements Media interface to demonstrate multiple inheritance through interfaces.

EBooks support various file formats, DRM protection, and provide reading time estimation based on word count.

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

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from class com.university.bookstore.model.Material

  `Material.MaterialType`

  ### Nested classes/interfaces inherited from interface com.university.bookstore.model.Media

  `Media.MediaQuality`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `EBook(String id, String title, String author, double price, int year, String fileFormat, double fileSize, boolean drmEnabled, int wordCount, Media.MediaQuality quality)`
  Constructs a new EBook with validation.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  Materials are equal if they have the same ID.
  `String`
  `getAuthor()`
  Gets the author of the e-book.
  `String`
  `getCreator()`
  Abstract method to get the creator/author/artist of the material.
  `String`
  `getDescription()`
  `double`
  `getDiscountRate()`
  Hook method for discount rate.
  `String`
  `getDisplayInfo()`
  Abstract method to get a formatted display string.
  `int`
  `getDuration()`
  Gets the duration of the media in minutes.
  `String`
  `getFileFormat()`
  Gets the file format of the ebook.
  `double`
  `getFileSize()`
  Gets the file size in MB.
  `String`
  `getFormat()`
  Gets the file format of the media.
  `Media.MediaQuality`
  `getQuality()`
  Gets the quality setting for the media.
  `int`
  `getReadingTimeMinutes()`
  Calculates estimated reading time in minutes based on average reading speed.
  `int`
  `getWordCount()`
  Gets the word count of the book.
  `int`
  `hashCode()`
  `boolean`
  `isDrmEnabled()`
  Checks if DRM is enabled.
  `boolean`
  `isStreamingOnly()`
  Checks if the media requires an internet connection.
  `String`
  `toString()`

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

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

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

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

  ### Methods inherited from interface com.university.bookstore.model.Media

  `estimateDownloadTime, getPlaybackInfo`

- ## Constructor Details

  - ### EBook

    public EBook(String id, String title, String author, double price, int year, String fileFormat, double fileSize, boolean drmEnabled, int wordCount, Media.MediaQuality quality)
    Constructs a new EBook with validation.
    Parameters:
      `id` - unique identifier
      `title` - the book title
      `author` - the author name
      `price` - the price in dollars
      `year` - the publication year
      `fileFormat` - the file format (PDF, EPUB, or MOBI)
      `fileSize` - the file size in MB
      `drmEnabled` - whether DRM is enabled
      `wordCount` - the number of words in the book
      `quality` - the media quality
    Throws:
      `IllegalArgumentException` - if validation fails

- ## Method Details

  - ### getCreator

    public String getCreator()
    Description copied from class: `Material`
    Abstract method to get the creator/author/artist of the material. Implementation varies by material type.
    Specified by:
      `getCreator` in class `Material`
    Returns:
      the creator's name

  - ### getAuthor

    public String getAuthor()
    Gets the author of the e-book.
    Returns:
      the author

  - ### 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.
    Specified by:
      `getDisplayInfo` in class `Material`
    Returns:
      formatted display string

  - ### getDiscountRate

    public double getDiscountRate()
    Description copied from class: `Material`
    Hook method for discount rate. Default is no discount. Subclasses can override to provide type-specific discounts.
    Overrides:
      `getDiscountRate` in class `Material`
    Returns:
      discount rate between 0.0 and 1.0

  - ### getReadingTimeMinutes

    public int getReadingTimeMinutes()
    Calculates estimated reading time in minutes based on average reading speed.
    Returns:
      estimated reading time in minutes

  - ### getFileFormat

    public String getFileFormat()
    Gets the file format of the ebook.
    Returns:
      the file format

  - ### getFileSize

    public double getFileSize()
    Gets the file size in MB.
    Specified by:
      `getFileSize` in interface `Media`
    Returns:
      the file size

  - ### isDrmEnabled

    public boolean isDrmEnabled()
    Checks if DRM is enabled.
    Returns:
      true if DRM is enabled

  - ### getWordCount

    public int getWordCount()
    Gets the word count of the book.
    Returns:
      the word count

  - ### getQuality

    public Media.MediaQuality getQuality()
    Description copied from interface: `Media`
    Gets the quality setting for the media.
    Specified by:
      `getQuality` in interface `Media`
    Returns:
      quality descriptor

  - ### getDescription

    public String getDescription()

  - ### getDuration

    public int getDuration()
    Description copied from interface: `Media`
    Gets the duration of the media in minutes.
    Specified by:
      `getDuration` in interface `Media`
    Returns:
      duration in minutes

  - ### getFormat

    public String getFormat()
    Description copied from interface: `Media`
    Gets the file format of the media.
    Specified by:
      `getFormat` in interface `Media`
    Returns:
      format string (e.g., "MP3", "MP4", "WAV")

  - ### isStreamingOnly

    public boolean isStreamingOnly()
    Description copied from interface: `Media`
    Checks if the media requires an internet connection.
    Specified by:
      `isStreamingOnly` in interface `Media`
    Returns:
      true if streaming required, false if downloadable

  - ### equals

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

  - ### hashCode

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

  - ### toString

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