#C4425. Library Book Loan Management
Library Book Loan Management
Library Book Loan Management
You are required to implement a simple library management system that handles book loans and returns. The system supports three operations:
loan
: Loan out a book. This operation should returnTrue
if the book was available, andFalse
if it was already loaned out.return
: Return a book. This operation should returnTrue
if the book was currently loaned out, andFalse
if it was not.check
: Check the availability of a book. This operation should returnTrue
if the book is available (i.e. not loaned out) andFalse
otherwise.
The system behaves as follows. Initially, all books are available. When performing a loan
operation on a book with identifier \( id \), if the book is available then it will be loaned, and subsequent operations will reflect this change until the book is returned.
Your program should read a series of commands from standard input and output the result of each command to standard output.
inputFormat
The first line of input contains an integer \( T \) representing the number of operations.
Each of the next \( T \) lines contains a command in one of the following formats:
loan id
return id
check id
Here, id
is an integer representing the unique identifier of a book.
outputFormat
For each command, output a single line with either True
or False
indicating the result of the operation.
5
loan 1
loan 1
check 1
return 1
check 1
True
False
False
True
True
</p>