ooad1-2 Exercise 1: The Loan Lifecycle as a State Diagram ========================================================= loan.state.mmd (Mermaid 12.1.0): stateDiagram-v2 [*] --> OnLoan : borrowed OnLoan --> Overdue : due date passes OnLoan --> Returned : returned Overdue --> Returned : returned (fine due) Returned --> [*] Render and output (render_diagrams.py from this chapter): $ py render_diagrams.py ex1 rendered ex1\loan.state.mmd -> loan.state.mmd.svg (29 KB) What you should see: a filled start dot, a box OnLoan, a branch to Overdue and to Returned, Overdue also leading to Returned, and an end marker after Returned. Event labels ("borrowed", "due date passes", "returned", "returned (fine due)") sit on the arrows. WHY THIS WORKS AS AN ANSWER --------------------------- A state diagram names the states an object can be in and what moves it between them. The loan has three: it is OnLoan after it starts, it becomes Overdue when the due date passes (an event, not something a person does), and either state ends in Returned. Chapter 8 returns to this with guards and actions and implements it in code. Note that [*] is the notation for both start and end.