2. Single Responsibility
EasySOLID2 hidden requirements
Giving a class one reason to change, by letting each collaborator own its own job
Order works out its own tax and formats its own receipt. Both are correct, and the tests pass.
It was handed a TaxRules and a ReceiptWriter and uses neither — the arithmetic and the formatting are written inline.
Rewrite Order so the tax comes from taxRules and the wording comes from receiptWriter. Nothing else needs to change.
Run compiles every file and runs Tests.java — the tests you can read.
Submit runs those again, then applies 2 requirements you have not seen, one at a time.
Your code is never edited. Each requirement is added to the project as it stands. If the design is right, nothing you wrote has to change.
- Ctrl/⌘ + Enter runs the tests
Run the tests to see where you are.
Hidden requirements
Stdout
TERMINALPROBLEMSOUTPUT
Try:
honeytrap shell. Two commands are wired up: cd and cat.