Class PrintedBook
java.lang.Object
com.university.bookstore.model.Material
com.university.bookstore.model.PrintedBook
- All Implemented Interfaces:
Comparable<Material>
Represents a physical printed book in the bookstore inventory.
Extends Material class to demonstrate inheritance.
This class maintains backward compatibility with the original Book class while integrating into the new polymorphic material hierarchy.
- 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 -
Constructor Summary
ConstructorsConstructorDescriptionPrintedBook(String isbn, String title, String author, double price, int year) Convenience constructor for backward compatibility.PrintedBook(String isbn, String title, String author, double price, int year, int pages, String publisher, boolean hardcover) Creates a new PrintedBook with validation. -
Method Summary
Modifier and TypeMethodDescriptiondoubleestimateReadingTime(int wordsPerMinute) Calculates estimated reading time based on average reading speed.Abstract method to get the creator/author/artist of the material.doubleHook method for discount rate.Abstract method to get a formatted display string.getIsbn()intgetPages()booleantoString()
-
Constructor Details
-
PrintedBook
public PrintedBook(String isbn, String title, String author, double price, int year, int pages, String publisher, boolean hardcover) Creates a new PrintedBook with validation.- Parameters:
isbn- the International Standard Book Numbertitle- the book titleauthor- the primary authorprice- the price in dollarsyear- the publication yearpages- number of pagespublisher- the publishing companyhardcover- true if hardcover, false if paperback
-
PrintedBook
-
-
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
-
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
-
getIsbn
-
getAuthor
-
getPages
public int getPages() -
getPublisher
-
isHardcover
public boolean isHardcover() -
estimateReadingTime
public double estimateReadingTime(int wordsPerMinute) Calculates estimated reading time based on average reading speed.- Parameters:
wordsPerMinute- reading speed (typical: 200-250)- Returns:
- estimated hours to read
-
toString
-