Confirm the Assignment
Before diving into the analysis, it’s essential to review the full assignment requirements.
Analysis
After analyzing the prompt, we can outline the overall framework for the CSG Object Calculator.
Items Outside Core Logic
We can note there are two requirements that sit outside the core logic, and they’re not difficult to implement.
__str__ is primarily used to override what gets printed when you print an object, typically turning it into something human-readable. For example, you can override it so printing becomes CSG<Label> for easy reading.
__setattr__ is invoked when creating or modifying member attributes in a class. Since the prompt asks us to force all spheres to be polygonal, we only need to check that the created object is indeed a sphere and then switch its type to polygon.
没有评论:
发表评论