Class PrintedBook

java.lang.Object
com.university.bookstore.model.Material
com.university.bookstore.model.PrintedBook
All Implemented Interfaces:
Comparable<Material>

public class PrintedBook extends 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
  • 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 Number
      title - the book title
      author - the primary author
      price - the price in dollars
      year - the publication year
      pages - number of pages
      publisher - the publishing company
      hardcover - true if hardcover, false if paperback
    • PrintedBook

      public PrintedBook(String isbn, String title, String author, double price, int year)
      Convenience constructor for backward compatibility.
  • 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
    • 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
    • getIsbn

      public String getIsbn()
    • getAuthor

      public String getAuthor()
    • getPages

      public int getPages()
    • getPublisher

      public String 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

      public String toString()
      Overrides:
      toString in class Material