Practice · 2 of 2
Reporter Injection
CHALLENGE
Difficulty: intermediate+25 XP
Create a class Order totals calculator: Order(items) where items is a list of prices. Its total() returns the sum. Add a constructor parameter reporter=None; if provided, total() must call reporter(total_value) once. This is dependency injection for observability.
Press Submit to check your solution.
Back to lesson: Practice: Composition Drills