Practice ยท 1 of 3
Milestone 1: Validated Domain
Build the domain in Solution:
- static class InvalidExpenseException extends RuntimeException โ
carries String problem (getter).
- record Expense(String id, String category, int cents):
- constructor validates: id/category non-blank, cents > 0 โ failures
throw InvalidExpenseException with a specific problem message
(e.g. "blank category", "non-positive cents")
- Expense is a hash-contract value type (records already are โ note
WHY in a comment).
This is Module 1 + 6 fused: fail fast, exceptions carry data.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Capstone Milestones