runtime
262 / 500
question 262 Inheritance & Composition · easy

Payment fees that don't add up

Every payment method should offer fee(amount), returning the fee as a number, so total_fees can treat them all alike. Since two new methods were added, total_fees crashes. Fix the payment classes (not total_fees) so they all keep the same contract.

Contractevery payment class has fee(amount) returning a number
FeesCard: 1.5% rounded to 2 places; BankTransfer: 0.20; Voucher: 0; PayLater: 2.9% + 0.30, rounded to 2 places
Unchangedtotal_fees(payments) adds up method.fee(amount) for (method, amount) pairs

Loading your progress…

Payment fees that don't add up — Python practice · Runtime