Reputation: 1
Say I am modelling this scenario - what design pattern could I use to best model this?
The base class is a CellPhonePlan. CellPhonePlan has two properties:
Where StandardFeatures might include a value such as "200 minutes call time".
I also want to provide some addons to the standard CellPhonePlan. Such as
1) Family Plan
2) WeekendPlan
I want to be able to choose the StandardFeatures, FamilyPlan and WeekendPlan and have its price and features reflective of the options I have made. I also would like to know how to best represent this using a design pattern!
Thanks
Sorry I guess I didn't explain that too clearly. What I am after is having the base plan plus the family, plus the weekend. So all the values add up.
Upvotes: 0
Views: 152
Reputation: 6477
This looks like it could fit well into the Decorator pattern, if you really want to use a design pattern.
Upvotes: 1
Reputation: 112807
No design pattern needed...
class CellPhonePlan
{
int MonthlyPrice { get; set; }
List<string> Features { get; set; }
}
var standardPlan = new CellPhonePlan
{
MonthlyPrice = 10,
Features = new List<string>() { "200 minutes call time", "texting" }
};
var familyPlan = new CellPhonePlan
{
MonthlyPrice = 20,
Features = new List<string>() { "500 minutes call time", "texting", "shared between a family" }
};
var weekendPlan = new CellPhonePlan
{
MonthlyPrice = 5,
Features = new List<string>() { "200 minutes call time", "but you can only talk on weekends" }
};
Upvotes: 4