public class Book {
    private static int bookCount = 0;
    private String title;
    private int id;
    public Book(String title) {
      this.title = title;
      this.id = ++bookCount;
    }
    public String getTitle() {
      return title;
    }
    public static int getBookCount() {
      return bookCount;
    }
    public int getID() {
      return id;
    }
    public String toString() {
      return title;
    }
    public static void main(String[] args) {
      Book book1 = new Book("The Great Gatsby");
      Book book2 = new Book("To Kill a Mockingbird");
      
      System.out.println("Book 1 title: " + book1 + " (ID: " + book1.getID()+")");
      System.out.println("Book 2 title: " + book2 + " (ID: " + book2.getID()+")");
      System.out.println("Number of books in library: " + Book.getBookCount());
    }
  }
  Book.main(null);
Book 1 title: The Great Gatsby (ID: 1)
Book 2 title: To Kill a Mockingbird (ID: 2)
Number of books in library: 2
import java.time.LocalDateTime;
public class Book {
    private static int bookCount = 0;
    private int id;
    private String title;
    private LocalDateTime timeEntered;
    public Book(String title) {
        this.id = ++bookCount;
        this.title = title;
        this.timeEntered = LocalDateTime.now();
    }
    public String getTitle() {
        return this.title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public int getId() {
        return this.id;
    }
    public LocalDateTime getTimeEntered() {
        return this.timeEntered;
    }
    public static int getBookCount() {
        return bookCount;
    }
    public String toString() {
        return this.title;
    }
    public static void main(String[] args) {
        Novel novel = new Novel("To Kill a Mockingbird", "Harper Lee");
        Textbook textbook = new Textbook("Java Programming", "Oracle");
        System.out.println("Book: " + novel + " (ID: " + novel.getId() + ")");
        System.out.println("Author: " + novel.getAuthor());
        System.out.println("Time Entered: " + novel.getTimeEntered());
        System.out.println();
        System.out.println("Textbook: " + textbook + " (ID: " + textbook.getId() + ")");
        System.out.println("Publishing Company: " + textbook.getPublishingCompany());
        System.out.println("Time Entered: " + textbook.getTimeEntered());
        System.out.println();
        System.out.println("Total Books in Library: " + Book.getBookCount());
    }
}
class Novel extends Book {
    private String author;
    public Novel(String title, String author) {
        super(title);
        this.author = author;
    }
    public String getAuthor() {
        return this.author;
    }
    public void setAuthor(String author) {
        this.author = author;
    }
}
class Textbook extends Book {
    private String publishingCompany;
    public Textbook(String title, String publishingCompany) {
        super(title);
        this.publishingCompany = publishingCompany;
    }
    public String getPublishingCompany() {
        return this.publishingCompany;
    }
    public void setPublishingCompany(String publishingCompany) {
        this.publishingCompany = publishingCompany;
    }
}
Book.main(null);
Book: To Kill a Mockingbird (ID: 1)
Author: Harper Lee
Time Entered: 2023-04-21T09:22:18.280574

Textbook: Java Programming (ID: 2)
Publishing Company: Oracle
Time Entered: 2023-04-21T09:22:18.280856

Total Books in Library: 2