Programming Fundamentals Using C++

Project 03 · Library Management System

Modules 13–15 (Weeks 13–15) · structs, vector, references, file persistence — the first stateful project Outcomes: CLO-6…CLO-8 (PF-13…PF-15). Difficulty: ★★★☆☆ · Builds on P2.

1. Problem description

A campus reading room lends books to members. The desk currently uses a paper register that is lost weekly. Write a console program that keeps a catalog of books and a register of which are out, saves state to a file between runs, and produces the desk's three daily reports. This is your first project whose data outlives the program: persistence changes design.

2. Learning objectives

  1. Model records with a struct and manage a collection in std::vector.
  2. Use references for in/out parameters where copies would lie.
  3. Implement file round-tripping: load on start, save on change.
  4. Apply the skip-and-report loader: malformed lines are data, not crashes.
  5. Search by title (case-sensitive substring) and report by status.

3. Functional requirements

4. Non-functional requirements

5. Suggested data structures

6. User interaction design

loaded: 2 skipped: 1
menu (add|lend|return|find|report|quit): lend B-1001 Ali
ok
menu (add|lend|return|find|report|quit): report
books: 2 out: 1 available: 1
B-1001 -> Ali
menu (add|lend|return|find|report|quit): add
title: Dune
author: Herbert
added B-1003
menu (add|lend|return|find|report|quit): quit
saved: 3

7. Input validation requirements

8. Testing plan

#ClassScenarioExpected
T1round-tripadd 2, quit, restartloaded: 2 skipped: 0
T2corrupt linecatalog with 1 bad lineskipped: 1, others load
T3state machinelend → lend samesecond: not available
T4state machinereturn → returnsecond: no such id only if id absent; else ok→ok
T5searchfind du against Dunehit; find zz → none
T6id policyadd after max id B-1007next is B-1008
T7persistencelend, kill program (EOF), restartlend survived (saved on change)
T8write-protectread-only file/dircannot save, exit 2
T9separatortitle A;Brejected, nothing added
T10empty catalogfresh file absentloaded: 0 skipped: 0, reports all zero

9. Milestones

  1. M1: struct + vector + load with skip-and-report + report + T2/T10.
  2. M2: menu + add (id policy) + lend/return state machine + T3/T4/T6.
  3. M3: save-on-quit + save-on-change + T1/T7/T8.
  4. M4: find + hardening pass (VR4/VR5, T5/T9) + full test table.

10. Extension ideas ⚙

11. Assessment rubric (10 points when graded as homework)

PointsLine
0–2Load with skip-and-report; missing file handled (T2, T10)
0–2State machine: lend/return invariants hold (T3, T4)
0–3Persistence: round-trip, save-on-change, cannot-save path (T1, T7, T8)
0–2Search + reports exact (T5, FR3 report line)
0–2NFR1/NFR2/NFR5: vector+references, no raw pointers, contracts

Course-gate: does not compile with the contract → 0.

12. Student instructions

Work individually. Start from the file format — write a 3-line catalog.txt by hand and load it before writing any menu code. The skipped-counter and the round-trip test (T1) are the project's soul: a file you wrote must load clean. Deliverables: library.cpp, test_table.md (T1–T10), postmortem.md, and the sample catalog.txt you tested with. Zip as p03_<yourid>.zip. Use of new/delete or fixed-size arrays = scope violation under the scope-calibration line.

Programming Fundamentals Using C++ · C++17 · 16 weeksBack to top ↑