ooad1-1 Exercise 2: A Reservation Sketch =========================================== ex2.mmd (Mermaid source; rendered with @mermaid-js/mermaid-cli 12.0.0, Mermaid 12.1.0): classDiagram direction LR class Member { name } class Reservation { reservedOn } class Book { title } Member "1" --> "0..*" Reservation : places Reservation "*" --> "1" Book : holds a place for Render it with: mmdc -i ex2.mmd -o ex2.svg (Mermaid's online editor at mermaid.live also works; chapter 2 sets up the tools.) The rendered diagram is the picture: three boxes in a row, Member (name), Reservation (reservedOn) and Book (title), joined by two arrows labelled "places" and "holds a place for". Reading the multiplicities: - Member "1" --> "0..*" Reservation: each reservation belongs to exactly one member, and a member can have none, one or many reservations. - Reservation "*" --> "1" Book: each reservation is for exactly one book, and a book can have many reservations (a queue), or none. - The arrow points in the direction you can navigate: from a member to their reservations, and from a reservation to its book. Nothing says a book can list its reservations; if you need that, the diagram must change. WHY THIS WORKS AS AN ANSWER --------------------------- It is deliberately a sketch: no operations, no types, only the concepts the idea needs. Giving Reservation its own box (rather than a plain link between Member and Book) is the useful design decision, because a reservation has its own facts (the date it was placed), exactly as a loan does.