public class Book {
    private String title;
    private int id;
    private long creationTime;
    private long bookLife;
    private static int bookCount = 0;

    public Book(String title, long bookLife) {
        this.title = title;
        this.bookLife = bookLife;
        this.creationTime = System.nanoTime() / (long)1000000000;
        bookCount++;
        this.id = bookCount;
    }
    public String getTitle() {
        return title;
    }

    public int getId() {
        return id;
    }

    public long getBookLife() {
        return bookLife;
    }

    public static int getBookCount() {
        return bookCount;
    }

    public static int setBookCount() {
        return bookCount = 0;
    }

    public boolean isExpired() {
        long currentTime = System.nanoTime() / (long)1000000000;
        if (currentTime > creationTime + bookLife) {
            return true;
        } else {
            return false;
        }
        
    }

    @Override
    public String toString() {
        return this.title + ", " + this.id + ", " + this.bookLife + " days, " + this.isExpired();
    }

}
public class Novel extends Book {
   
    private String author;
    private int stamps;

    public Novel(String title, int bookLife, String author, int stamps) {
        super(title, bookLife);
        this.author = author;
        this.stamps = stamps;
    }

    public String getAuthor() {
        return author;
    }

    public boolean isExpired() {
        boolean expired = super.isExpired();
        if (expired && this.stamps < 3) {
            return true;
        } else {
            return false;
        }
        
    }

    public String toString() {
        return super.toString() + ", " + this.author;
    }

}
public class Textbook extends Book {
   
    private String publishingCompany;

    public Textbook(String title, int bookLife, String publishingCompany) {
        super(title, bookLife);
        this.publishingCompany = publishingCompany;
    }

    public String getPublishingCompany() {
        return publishingCompany;
    }

    public String toString() {
        return super.toString() + ", " + this.publishingCompany;
    }

}
public class Main {
    public static void main(String[] args) {

        Book.setBookCount();
        Book book1 = new Book("Red Rose", 3);
        Novel novel1 = new Novel("Midnight Library", 2, "John", 2);
        Textbook textbook1 = new Textbook("AP CSA", 4, "Mort");
        System.out.println("Book 1: " + book1.toString());
        System.out.println("Book 2: " + novel1.toString());
        System.out.println("Book 3: " + textbook1.toString());
        System.out.println("Total Books: " + Book.getBookCount());

        try {
            Thread.sleep(3000);
        } catch(Exception e) {
            e.printStackTrace();
        }

        System.out.println("Book 1: " + book1.toString());
        System.out.println("Book 2: " + novel1.toString());
        System.out.println("Book 3: " + textbook1.toString());
    }
}
Main.main(null);
Book 1: Red Rose, 1, 3 days, false
Book 2: Midnight Library, 2, 2 days, false, John
Book 3: AP CSA, 3, 4 days, false, Mort
Total Books: 3
Book 1: Red Rose, 1, 3 days, false
Book 2: Midnight Library, 2, 2 days, true, John
Book 3: AP CSA, 3, 4 days, false, Mort