Code AnalysisIntermediate 60s
Analyze: LSP behavioral subtyping break
Which principle does this code violate?
class Account:
withdraw(amount):
if amount > self.balance: throw Error
self.balance -= amount
class CheckingAccount extends Account:
withdraw(amount):
if amount > self.balance - 100: throw Error
self.balance -= amount
// Client assumes Account contract: can withdraw up to balance
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.