if这里不复杂阿,如果不用if 那用case ,这里条件不多,还是if可以
解决方案 »
- 高分请教架构问题,请指导
- C#怎么调用Win7的信息框?
- 这个可以用来判断吗?
- 问下XSD文件怎么用,,,着急,,,,在线等!!!!明天结贴
- ASP.NET在本机上用IIS浏览 都需要按什么
- 惊奇发现,CHROME竟然在页面上内置了双词
- 急急急
- 請問怎麼才能將GRIDVIEW中的數據導到EXCEL並由用戶選擇路徑存入客戶端,並在字符型或所有字段值前加入單引號?
- c#中,如何组织主从表中的从表的输入?on line waiting!
- 简单问题:oicq的注册向导的窗口怎么做?怎么让他的下一步打开另一个窗口?上一步也是!
- webbrowser.navigated(url)中的url是一个远程网站,需要用户名密码登陆
- 关于C# DataGridView排序的疑惑
1. 部分打折和返现的业务逻辑写到了现金收取工厂中
2. 打折、返现、VIP之间关系混乱,首先你要明确这三者之间的关系。CashContext功只需要协调打折、返现、VIP三者之间的关系,例如多少钱的返现多少、多少数量的打几折这种逻辑是在打折和返现类中进行判断的。
{
static void Main(string[] args)
{
Console.WriteLine("请依次按提示输入:");
Console.WriteLine("输入购买金额:");
var inputMoney = double.Parse(Console.ReadLine());
Console.WriteLine("输入购买数量:");
var inputNumbers = int.Parse(Console.ReadLine());
Console.WriteLine("@输入是否是会员: 0:非会员; 1:银卡会员; 2:金卡会员;");
var inputVip = int.Parse(Console.ReadLine());
var Person1 = new CashContext(inputMoney, inputNumbers,inputVip);
Console.ReadLine();
}
}
//现金收取父类
internal abstract class CashReap
{
public abstract double AcceptCash(double money);
}
//打折子类
internal class CashDiscount : CashReap
{
......
public int ProductNumbers { get; set; } // 此处需要增加根据数量自动换算折扣率的代码
......
}
//返现子类
internal class CashRebate : CashReap
{
......
public float TotalPrices { get; set; } // 此处需要增加根据总金额自动换算返还金额的算法
......
}
//VIP类
internal class VipDiscount : CashReap
{
......
}
//现金收取工厂
internal class CashContext
{
private CashReap _cReap;
public CashContext(double totalMoney,int productnumbers,int isVip)
{
// 活支折扣
CashDiscount cs1 = new CashDiscount();
cs1.productnumbers == 1;
totalMoney = cs1.AcceptCash(totalMoney);
// VIP折扣
VipDiscount cs2 = new VipDiscount(isVip);
totalMoney = cs2.AcceptCash(totalMoney);
// 返现
CashRebater cs3 = new CashRebate();
totalMoney = cs3.AcceptCash(totalMoney)
Console.WriteLine("应付总额为: "+ totalMoney.tostring() +" 元");
}
}