Object-Oriented Programming · Amazon · Medium
Strategy-Pattern Discount Engine Start with the one-sentence story the interviewer wants before any class names come up: computeTotal walks the cart line by line, asks every configured discount whether it applies to that line for this customer, adds up the money each applicable discount removes, and subtracts that sum from the line's subtotal before adding it to the running total. Everything else is detail hanging off that loop. The engine never knows which kinds of discount…