Practice · 4 of 4
Transfer with cleanup discipline
CHALLENGE
Difficulty: beginner+25 XP
Implement static decimal Transfer(decimal from, decimal to, decimal amount) inside a running total model: throws ArgumentException for non-positive amount, throws InvalidOperationException when amount > from, otherwise returns to + amount. Also implement static bool AuditTrail(List<string> log, Action action): runs action, always appending "done" to the log afterwards (even when action throws, log gets "done" and the exception propagates); returns true only if action completed without throwing.
Press Submit to check your solution.
Back to lesson: Practice: Error handling workout