Design patterns 我应该使用什么样的设计模式?
假设我正在模拟这个场景-我可以使用什么设计模式来最好地模拟这个场景 基类是CellPhonePlan。CellPhonePlan有两个属性:Design patterns 我应该使用什么样的设计模式?,design-patterns,Design Patterns,假设我正在模拟这个场景-我可以使用什么设计模式来最好地模拟这个场景 基类是CellPhonePlan。CellPhonePlan有两个属性: 每月租金 类型字符串、标准功能的列表 其中StandardFeatures可能包括一个值,例如“200分钟通话时间” 我还想为标准手机计划提供一些插件。比如 1) 家庭计划 整数价格 类型字符串、特征的列表 2) 周末计划 整数价格 类型字符串、特征的列表 我希望能够选择StandardFeatures、FamilyPlan和WeekendPl
- 每月租金
- 类型字符串、标准功能的列表
- 整数价格
- 类型字符串、特征的列表
- 整数价格
- 类型字符串、特征的列表
对不起,我想我没有解释清楚。我想要的是基本计划加上家庭,再加上周末。所以所有的值加起来。不需要设计模式
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" }
};
class-CellPhonePlan
{
int MonthlyPrice{get;set;}
列出要素{get;set;}
}
var standardPlan=新手机计划
{
月电价=10,
Features=new List(){“200分钟通话时间”,“发送短信”}
};
var familyPlan=新手机计划
{
月电价=20,
Features=新列表(){“500分钟通话时间”、“发短信”、“家庭共享”}
};
var weekendPlan=新手机计划
{
月电价=5,
Features=new List(){“200分钟通话时间”,“但您只能在周末通话”}
};
不需要设计模式
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" }
};
class-CellPhonePlan
{
int MonthlyPrice{get;set;}
列出要素{get;set;}
}
var standardPlan=新手机计划
{
月电价=10,
Features=new List(){“200分钟通话时间”,“发送短信”}
};
var familyPlan=新手机计划
{
月电价=20,
Features=新列表(){“500分钟通话时间”、“发短信”、“家庭共享”}
};
var weekendPlan=新手机计划
{
月电价=5,
Features=new List(){“200分钟通话时间”,“但您只能在周末通话”}
};
如果您真的想使用设计模式,它看起来很适合。如果您真的想使用设计模式,它看起来很适合。这太完美了,谢谢!现在,我将尝试找出如何将其标记为答案。这太完美了,谢谢!我现在将尝试找出如何将其标记为答案。