Skip to main content

Practice ยท 1 of 1

Parse the ledger line

Implement parse(String line) in the provided skeleton: split on | into exactly 4 fields; return new Transaction(date, label, Direction.valueOf(field.toUpperCase()), Double.parseDouble(amount)). The record's compact constructor already validates - let its exceptions propagate unchanged (callers need the real reason).

Difficulty: intermediate

Back to lesson: Practice: Practice: Parse the Ledger