Project: Library System

Build a library management system. This project practises aggregation (Library holds Books and Members), state management (book availability), and cross-object interaction (borrowing links Members and Books).

Class Relationships

Library ◇────── Book     (aggregation: books exist independently)
Library ◇────── Member   (aggregation: members exist independently)
Member  ◇────── Book     (borrowed_books list — weak reference)

All three are aggregation relationships — no object owns another.

Borrow / Return Logic

  • borrow_book: find book by isbn, check is_available, set it to False, append to member's borrowed_books
  • return_book: find book by isbn in member's list, set is_available to True, remove from borrowed_books
  • Find members/books by looping through your internal lists and matching id/isbn

Your Task

Implement all the pass stubs. The borrow/return cycle is the most complex part — break it down step by step. Once complete, the test block at the bottom should produce the expected output.

Section 1/3Class Relationships

Class Relationships

All three are aggregation relationships — no object owns another.

Project: Library System

Build a library management system. This project practises aggregation (Library holds Books and Members), state management (book availability), and cross-object interaction (borrowing links Members and Books).

Class Relationships

Library ◇────── Book     (aggregation: books exist independently)
Library ◇────── Member   (aggregation: members exist independently)
Member  ◇────── Book     (borrowed_books list — weak reference)

All three are aggregation relationships — no object owns another.

Output:

Click "Check" to run your code.