我使用什么设计模式?

问题描述:

假设我正在建模这个场景 - 我可以用什么样的设计模式来最好地建模?我使用什么设计模式?

基类是一个CellPhonePlan。 CellPhonePlan有两个属性:

  • INT MonthlyPrice字符串类型的
  • 名单,StandardFeatures

凡StandardFeatures可能包括一个值,如 “200分钟通话时间”。

我也想给标准的CellPhonePlan提供一些插件。如

1)家庭计划

  • INT价格
  • 类型的字符串列表,功能

2)WeekendPlan

  • INT价格
  • 类型的列表字符串,功能

我希望能够选择StandardFeatures,FamilyPlan和WeekendPlan,并且它的价格和功能反映了我所做的选项。我也想知道如何用设计模式来最好地代表这个!

感谢


对不起,我想我没有解释得太清楚。我所追求的是基本计划加上家庭,再加上周末。所以所有的值加起来。

需要任何设计图案......

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" } 
}; 

这看起来可能很好地成为Decorator pattern,如果你真的想使用设计模式。

+0

这是完美的谢谢!我现在试着弄清楚如何将它标记为答案。 – Lothar 2010-11-09 16:01:19