Practice ยท 3 of 3
Extract, Don't Duplicate
Re-implement static List<String> auditLines(List<Integer> amountsCents)
with EXTRACTED helpers (the grader inspects that helpers exist):
- static boolean isSuspicious(int cents) โ |amount| > 10000
- static String describe(int cents) โ "CREDIT " + cents when >= 0,
"DEBIT " + (-cents) otherwise
- auditLines returns one line per amount: describe(a) plus
" [SUSPECT]" appended when isSuspicious(a).
The old version (comments in starter) had the threshold and format
duplicated three times โ your version states each once.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Clean Code Lab