Beispiel #1
0
        /// <summary>
        /// 跟用户交互的过程
        /// </summary>
        public void AskBuying()
        {
            Console.WriteLine("欢迎光临,请问你需要些什么");
            Console.WriteLine("我们有 Acer,SanSung,JiangYou,Banana");
            string strType = Console.ReadLine();

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

            //去仓库取货
            ProductFatter[] pros = ck.QuPros(strType, count);
            //计算价钱
            double realMoney = GetMoney(pros);

            Console.WriteLine("您总共应付{0}元", realMoney);
            Console.WriteLine("请选择您的打折方式:1--不打折  2--打九折  3--打85折  4--买300送50  5--买500送100");
            string input = Console.ReadLine();
            //通过简单工厂设计模式 根据用户输入获得一个打折对象
            CalFather cal        = GetCal(input);
            double    totalMoney = cal.GetTotalMoney(realMoney);

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