Module 3 – Turn repeated reasoning into small components
Test the contract at its edge
Build a table of total, done, and expected remaining values. Include no lessons, no completed work, one remaining lesson, equality, and a completed count above the total. Explain why the final case returns zero in this exercise; another application might reject it instead, so the policy belongs in the specification.
Ask a reviewer to propose a case you missed. If you change the policy, revise the tests and explanation together. As an extension, move the function into a package and show that the same tests still pass. Keep the calculation separate from printing so it is easy to reuse in another interface.
Complete this lesson
Answer every check correctly to earn your lesson certificate. Feedback helps you review and try again.
Sign in · Save your progress and earn a certificate for this lesson.