There is a class Book, which has the attributes bookID, title and author. There are two categories of books, TextBooks and ReferenceBooks.
The text books can be borrowed by a user while the reference books cannot be. There is an extra attribute status (default value is Available)
and borrowedUser in the class TextBooks. There is an interface Borrowable which has methods checkIn and checkOut. The class Book implements
the Borrowable interface (Think and decide whether class Book is an abstract class or not).
The functionality of the checkIn and checkOut methods in TextBooks class is as follows:
checkIn : should set status attribute as Borrowed and should set the value of borrowedUser.
checkOut : should set status attribute as Available
The functionality of the checkIn and checkOut methods in ReferenceBooks class is as follows:
checkIn : display “Invalid”
checkOut : display “Cannot be borrowed”
Sample Input and Output:
- Add Reference Book
- Add Text Book
- Check-Out
- Check-In
- List Books
- Exit
Enter ID, Title and Author (Line by line)
101
Data Structures and Algorithms
Cormen
Enter ID, Title and Author (Line by line)
102
Programming Ruby
Thomas
ReferenceBook: 101: Data Structures and Algorithms: Cormen
TextBook: 102: Programming Ruby: Thomas: Available
Enter Book ID: 101
Cannot be borrowed
Enter Book ID: 102
Enter Username: Ram
ReferenceBook: 101: Data Structures and Algorithms: Cormen
TextBook: 102: Programming Ruby: Thomas: Borrowed by Ram
Enter Book ID: 102
ReferenceBook: 101: Data Structures and Algorithms: Cormen
TextBook: 102: Programming Ruby: Thomas: Available