Structure a Pizza-Ordering System with Four Discount Policies
Company: American
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Online Assessment
Design the code structure for a pizza-ordering system that supports four discount schemes. Explain how pizza and order data are represented and how discount calculations can be implemented, combined under a declared policy, and tested.
### Constraints
The four schemes' exact formulas, eligibility rules, and combination policy are not supplied. Preserve four independently specified schemes without inventing their meanings. Pizza attributes, prices, currency precision, and the required output must also be clarified. This is a code-design discussion, not an executable pricing contract.
### Clarifying Questions
- What attributes define a pizza and determine its undiscounted price?
- What are the exact rules of each of the four schemes, including thresholds and exclusions?
- Are schemes mutually exclusive, stacked in an order, or selected to minimize the total?
- At which stage is rounding applied, and how are invalid quantities or prices handled?
```hint Give each scheme a common evaluation boundary
A shared interface can make four policies easier to test without assuming that their eligibility or formulas are identical.
```
### What a Strong Answer Covers
- Clear pizza/order data structures and exact monetary representation.
- Separate discount policies with a declared composition or selection layer.
- Validation, boundary tests, reproducible totals, and maintainable code organization.
### Follow-up Questions
- How would adding a fifth scheme affect the existing implementation?
- How would you explain why an order did or did not qualify for a discount?
Overview: Design pizza and order data structures with four independently specified discount policies, exact pricing, composition rules, and explainable results.
Design the code structure for a pizza-ordering system that supports four discount schemes. Explain how pizza and order data are represented and how discount calculations can be implemented, combined under a declared policy, and tested.
Constraints
The four schemes' exact formulas, eligibility rules, and combination policy are not supplied. Preserve four independently specified schemes without inventing their meanings. Pizza attributes, prices, currency precision, and the required output must also be clarified. This is a code-design discussion, not an executable pricing contract.
Clarifying Questions Guidance
What attributes define a pizza and determine its undiscounted price?
What are the exact rules of each of the four schemes, including thresholds and exclusions?
Are schemes mutually exclusive, stacked in an order, or selected to minimize the total?
At which stage is rounding applied, and how are invalid quantities or prices handled?
What a Strong Answer Covers Guidance
Clear pizza/order data structures and exact monetary representation.
Separate discount policies with a declared composition or selection layer.
Validation, boundary tests, reproducible totals, and maintainable code organization.
Follow-up Questions Guidance
How would adding a fifth scheme affect the existing implementation?
How would you explain why an order did or did not qualify for a discount?