We want to realize a program to handle books rented at a library. For each book the following information is stored: author and title of the book, status of the book (rented or not), name of the person who rented the book.
Write a class
Book that implements the following methods:
Book(String a, String t): constuctor that creates a book with author
tthat is initially not rented;
String toString(): that returns a string with all the information about the book;
void rentTo(String n): that modifies the information about the book by specifying that the book has been rented by the person whose name is
void returned(): that modifies the information about the book by specifying that it has been returned to the library;
boolean isRented(): that verifies whether a book is currently being rented;
String whoHasBook(): that returns the name of the person that currently rents the book, or
nullif the book is currently not rented;
String getAuthor(): that returns the author of the book;
String getTitle(): that returns the title of the book;
Write a class
UseBook, client of
Book, that contains
the following public static methods:
static int countAvailableBooks(Book b1, Book b2, Book b3): that, given three books
b3, returns the number of books among
b3that are currently not rented.
static int countRentedBooks(Book b, String a): that, given an archive
archof books, rappresented simply as an array of books, and the name
authof an author, returns the number of books of the author
archthat are currently rented.