Library Book Management with Classes

C++ Medium classes

Task «Library Book Management with Classes»

Implement the Book class to store information about a book: title (string), author (string), year of publication (integer), and status (available or issued, boolean). The class must contain a constructor to initialize all fields, as well as methods: setStatus(bool) to change the status, getInfo() to return a string with full information about the book. In main, create an array of books (no more than 100), fill it with data from the input file, and process commands. The input first provides a number N — the number of books, then N lines with data: title author year_of_publication status (0 — available, 1 — issued). After that, a command is provided: 'print_all' — output information about all books; 'print_available' — output only available books; 'borrow <title>' — change the status of the book with the specified title to 'issued' (if the book is not found or is already issued, output a corresponding message).

Input Format

First line: integer N (1 ≤ N ≤ 100). Then N lines: title (string without spaces), author (string without spaces), year (integer), status (0 or 1). Then a line with a command (one of those described).

Output Format

For the commands 'print_all' and 'print_available' — output information about each book in the format: "Title: <title>, Author: <author>, Year: <year>, Status: <available/issued>" (each book on a new line). For the 'borrow' command — if the book is found and available, output "The book '<title>' has been issued." and change the status; if not found — "The book '<title>' not found."; if already issued — "The book '<title>' is already issued."

Examples

Example 1

INPUT
2 A B 1999 1 C D 2005 0 print_available
OUTPUT
Название: C, Автор: D, Год: 2005, Статус: доступна

Example 2

INPUT
1 X Y 2022 0 borrow X
OUTPUT
Книга 'X' выдана.

Example 3

INPUT
Война и мир,Роман Преступление и наказание,Роман 1984,Антиутопия Мастер и Маргарита,Роман
OUTPUT
Роман: 3 Антиутопия: 1
main.cpp