Exemple #1
0
        public CalFather GetCal(string input)
        {
            CalFather cal = null;

            switch (input)
            {
            case "1":
                cal = new CalNomal();
                break;

            case "2":
                cal = new CalRate(0.9);
                break;

            case "3":
                cal = new CalRate(0.85);
                break;

            case "4":
                cal = new CalMN(300, 50);
                break;

            case "5":
                cal = new CalMN(500, 100);
                break;
            }
            return(cal);
        }
Exemple #2
0
        public void AskBuyying()
        {
            Console.WriteLine("欢迎光临猫七家超市");
            Console.WriteLine("请问您需要什么?我们有HeTianDaZao、ShanXiZao、TanZao、ZiJinZao、YanTaiApple");
            string strTP = Console.ReadLine();

            Console.WriteLine("请问您需要多少");
            int count = Convert.ToInt32(Console.ReadLine());


            ProductFather [] pros = ck.QuPros(strTP, count);

            //计算价钱
            double AllMoney = GetMoney(pros);

            Console.WriteLine("您总共应付{0}元", AllMoney);
            Console.WriteLine("请您选择打折方式:1--不打折  2--打九折  3--打85折  4--买300送50  5--买500送100");
            string    InputXuan = Console.ReadLine();
            CalFather cal       = GetCal(InputXuan);
            double    DZMoney   = cal.GetTotalMoney(AllMoney);


            Console.WriteLine("以下是您购买物品的信息");
            foreach (var item in pros)
            {
                Console.WriteLine("货物编号:" + item.ID + "  货物名称:" + item.Name + "   货物单价" + item.Price);
            }
            Console.WriteLine("购买数量:{0}", count);
            Console.WriteLine("打完折后,您应付{0}元", DZMoney);
        }