Class EBook
java.lang.Object
com.university.bookstore.model.Material
com.university.bookstore.model.EBook
- All Implemented Interfaces:
Media,Comparable<Material>
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.MaterialTypeNested classes/interfaces inherited from interface com.university.bookstore.model.Media
Media.MediaQuality -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanMaterials are equal if they have the same ID.Gets the author of the e-book.Abstract method to get the creator/author/artist of the material.doubleHook method for discount rate.Abstract method to get a formatted display string.intGets the duration of the media in minutes.Gets the file format of the ebook.doubleGets the file size in MB.Gets the file format of the media.Gets the quality setting for the media.intCalculates estimated reading time in minutes based on average reading speed.intGets the word count of the book.inthashCode()booleanChecks if DRM is enabled.booleanChecks if the media requires an internet connection.toString()Methods inherited from class com.university.bookstore.model.Material
compareTo, getDiscountedPrice, getId, getPrice, getTitle, getType, getYearMethods 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 identifiertitle- the book titleauthor- the author nameprice- the price in dollarsyear- the publication yearfileFormat- the file format (PDF, EPUB, or MOBI)fileSize- the file size in MBdrmEnabled- whether DRM is enabledwordCount- the number of words in the bookquality- the media quality- Throws:
IllegalArgumentException- if validation fails
-
-
Method Details
-
getCreator
Description copied from class:MaterialAbstract method to get the creator/author/artist of the material. Implementation varies by material type.- Specified by:
getCreatorin classMaterial- Returns:
- the creator's name
-
getAuthor
-
getDisplayInfo
Description copied from class:MaterialAbstract method to get a formatted display string. Each material type should provide its own formatting.- Specified by:
getDisplayInfoin classMaterial- Returns:
- formatted display string
-
getDiscountRate
public double getDiscountRate()Description copied from class:MaterialHook method for discount rate. Default is no discount. Subclasses can override to provide type-specific discounts.- Overrides:
getDiscountRatein classMaterial- 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
-
getFileSize
public double getFileSize()Gets the file size in MB.- Specified by:
getFileSizein interfaceMedia- 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
Description copied from interface:MediaGets the quality setting for the media.- Specified by:
getQualityin interfaceMedia- Returns:
- quality descriptor
-
getDescription
-
getDuration
public int getDuration()Description copied from interface:MediaGets the duration of the media in minutes.- Specified by:
getDurationin interfaceMedia- Returns:
- duration in minutes
-
getFormat
-
isStreamingOnly
public boolean isStreamingOnly()Description copied from interface:MediaChecks if the media requires an internet connection.- Specified by:
isStreamingOnlyin interfaceMedia- Returns:
- true if streaming required, false if downloadable
-
equals
-
hashCode
-
toString
-