public void AskBuy() { Console.WriteLine("Welcome to supermarket, please you need why?"); Console.WriteLine("We have Lenove computer and Vegtable, and Car and Ice"); string Type = Console.ReadLine(); Console.WriteLine("You want need how much"); int Count = Convert.ToInt32(Console.ReadLine()); //去仓库取货 Commodity[] comms = _lib.OutputGoods(Type, Count); //要钱 double Money = GetMoney(comms); Console.WriteLine("You give me Preferential befor{0}¥", Money); //提示客户有那些打折方式 Console.WriteLine("Please select your Preferential way"); Console.WriteLine("1. not; 2.99; 3.85; 4.Buy 300¥send 50¥"); string Input = Console.ReadLine(); Preferential OutMoney = SelectWay(Input); double TotalMoney = OutMoney.PreferentialWay(Money); Console.WriteLine("You give me {0} ¥", TotalMoney); }
public Preferential SelectWay(string Input) { Preferential way = null; switch (Input) { case "1": return(way = new NormalMoney()); case "2": return(way = new Preferential99(0.99)); case "3": return(way = new Preferential99(0.85)); } return(way); }