Practice · 5 of 5
Debug the Register class
CHALLENGE
Difficulty: beginner+25 XP
This cash-register class corrupts its state: scan() forgets to count items, and undo() drives the total negative when the register is empty. Trace two scans and one undo, fix both defects (signatures stay the same).
Press Submit to check your solution.
Back to lesson: Practice: Design reps