question 266 Inheritance & Composition · medium
Quotes that miss a delivery option
quote_all decides each delivery option's cost with an isinstance chain. When pallet delivery was added it never appeared in the quotes, and adding it to the chain crashed because its cost needs a distance too. Make every option answer cost(weight_kg) the same way (pallet delivery keeps its distance as an attribute), and make quote_all work for any option without naming classes.
Options
Standard(), Express(), Pallet(distance_km); each with cost(weight_kg)Pallet
45 + 0.4 × distance_km, whatever the weight`quote_all(options, weight_kg)`
{class name: cost rounded to 2 places} for every option given