What this Python object-oriented coding problem tests
This is an easy coding problem that evaluates your ability to implement custom exception handling and class-level state management in Python. It combines basic language knowledge with practical warehouse-system design patterns.
The problem requires you to build a Product class that enforces a dynamic capacity constraint by tracking the total number of active instances. You'll need to understand how Python's __init__ and __del__ methods work, how to raise custom exceptions with formatted messages, and how to maintain shared state across instances. The solution hinges on correctly incrementing a counter when an instance is created and decrementing it when an instance is garbage-collected—but only if the capacity check passes before creation.
- Custom exception class design and inheritance
- Class variables vs. instance variables
- Lifecycle methods (
__init__, __del__)
- Conditional instance creation and error handling
- Interaction with external state (
Limit.get_limit())