I have an enum of phone conditions. At one point in my application I need to update a price based on the condition of the phone, e.g.
switch (condition)
{
case Condition.Good:
price = goodPrice;
break;
case Condition.ScreenCrack:
price = screenCrackPrice;
break;
case Condition.CameraCrack:
price = cameraCrackPrice;
break;
case Condition.BadBattery:
price = badBatteryPrice;
break;
case Condition.ScreenCrack | Condition.CameraCrack:
price = screenCrackCameraCrackPrice;
break;
case Condition.ScreenCrack | Condition.BadBattery:
price = screenCrackBadBatteryPrice;
break;
case Condition.CameraCrack | Condition.BadBattery:
price = cameraCrackBadBatteryPrice;
break;
case Condition.ScreenCrack | Condition.CameraCrack | Condition.BadBattery:
price = screenCrackCameraCrackBadBatteryPrice;
break;
}
Later on, the user may want to edit the price associated with that same condition. How can I do this without making another switch statement?
Aucun commentaire:
Enregistrer un commentaire