Curriculum

Curriculum

Build a Library Checkout Checker

Scenario

A reader may borrow a book only when it is available and they currently have fewer than three books. Return a boolean.

Selected choicePick a choice below
Result—

Try it yourself

Predict the results, then draw both decisions and write three tests.

Reveal the explanation
  1. Available book, 2 books already borrowed

    Expected true. The book is available and the reader is below the limit.

  2. Available book, 3 books already borrowed

    Expected false. The reader reached the limit.

  3. Unavailable book, 0 books already borrowed

    Expected false. The book must be available.

Review the agent’s comparison at two and three borrowed books. Run the tests and add one more case that checks both rules failing together.

Download shared test cases

Your turn

Build the checker and include a case where both rules fail.

Common mistake Allowing checkout when a reader already has exactly three books.

Check your work

The flowchart and tests show the exact limit and both independent reasons to decline.

Project brief

Basic
Draw the availability check and the three-book limit. Trace the three given examples.
Intermediate
Implement one checkout function and test two and three borrowed books.
Stretch
Add a test where both rules fail. Port the function or document how a second implementation would share the same cases.

What to hand in

Include your diagram, expected-result table, code, actual test output, and the commit or diff you reviewed.

Review criteria

  • Logic · Your diagram shows every required path and boundary.
  • Verification · The tests exercise the stated acceptance cases and the recorded results match the code.
  • Review · The change is focused and you can explain the decision it implements.