All challenges
Code AnalysisHard 60s

Violated principle in subclass override

A payment module contains: class FixedAmountDiscount: def apply(self, total): return total - 10 class PercentageDiscount(FixedAmountDiscount): def apply(self, total): if total <= 0: raise ValueError('bad total') return total * 0.9 # caller def final_price(discount, total): assert discount.apply(total) < total return discount.apply(total) Which design principle does PercentageDiscount violate, and why?

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle