Build a console-driven library system that supports:
- Adding a book (title, author, quantity)
- Displaying available books
- Borrowing a book
- Returning a book
- Quitting cleanly
ILibraryService/LibraryService— owns theLibraryentity and exposesAddBook,DisplayBooks,BorrowBook,ReturnBook.Book— title, author, quantity, andborrowedcount;Availableis derived (quantity - borrowed), not stored.- Command pattern — each menu action (
AddBookCommandRunner,BorrowBookCommandRunner,DisplayBookCommandRunner,ReturnBookCommandRunner,QuitCommandRunner) is its own class implementing a commonCommandRunnerabstraction, soProgram.csnever branches on user choice directly. CommandRunnerFactory— maps the user's menu input to the right command runner, keepingProgram.cs's loop a thin dispatch layer.IConsoleWrapper— abstracts console I/O behind an interface so command runners and the service are unit-testable without a real console.InvalidCommandException— surfaces bad menu input as a typed error instead of crashing the loop.- Unit tests (
Library_Management_Test) — one test class per command runner, plus the service itself.
C# / .NET 6
- Rebuild the solution
- Navigate to
/Library_Management/bin/debug/net6.0 - Run
Library_Management.exe - Menu: Add Book → Display Available Books → Borrow Book → Return Book → Quit