示例#1
0
文件: Class1.cs 项目: guipaa/PDF.NET
        static void TestModel()
        {
            //http://www.cnblogs.com/assion/archive/2011/05/13/2045253.html

            //我们创建几样商品
            GoodsStock RedWine = new GoodsStock() { GoodsName = "红酒", GoodsPrice = 1800, GoodsNumber = 10 };
            GoodsStock Condoms = new GoodsStock() { GoodsName = "安全套", GoodsPrice = 35, GoodsNumber = 10 };

            //我们创建几位顾客
            Customer Chunge = new Customer() { CustomerName = "春哥" };
            Customer Beianqi = new Customer() { CustomerName = "贝安琪" };
            Customer Noname = new Customer();

            //有一台收银机
            CashierRegisterMachines crManchines = new CashierRegisterMachines() { CashRegisterNo = "CR00011" };
            //当然,我们需要收银员啊
            Cashier CashierMM = new Cashier(crManchines) { CashierName = "收银员MM", WorkNumber = "SYY10011" };

           

            //顾客开始排队结帐了
            Queue<Customer> customerQueue = new Queue<Customer>();
            customerQueue.Enqueue(Chunge);
            customerQueue.Enqueue(Beianqi);
            customerQueue.Enqueue(Noname);

            //队伍过来,按先后顺序挨个收银喽
            foreach (var customer in customerQueue)
            {
                //收银
                CashierMM.CashRegister(customer);
            }

        }
示例#2
0
文件: Class1.cs 项目: guipaa/PDF.NET
        static void TestBIZ()
        {
            //我们创建几样商品
            GoodsStock RedWine = new GoodsStock() { GoodsName = "红酒", GoodsPrice = 1800, GoodsNumber = 10, SerialNumber ="J000111" };
            GoodsStock Condoms = new GoodsStock() { GoodsName = "安全套", GoodsPrice = 35, GoodsNumber = 10, SerialNumber ="T213000" };

            //我们创建几位顾客
            Customer Chunge = new Customer() { CustomerName = "春哥" };
            Customer Beianqi = new Customer() { CustomerName = "贝安琪" };
            Customer Noname = new Customer();

            //有一台收银机
            CashierRegisterMachines crManchines = new CashierRegisterMachines() { CashRegisterNo = "CR00011" };
            //当然,我们需要收银员啊
            Cashier CashierMM = new Cashier(crManchines) { CashierName = "收银员MM", WorkNumber = "SYY10011" };

            //顾客逛了一圈,选了自己想要的商品
            Chunge.LikeBuy(RedWine.TakeOut(1));
            Beianqi.LikeBuy(RedWine.TakeOut(1));
            Beianqi.LikeBuy(Condoms.TakeOut(1));
            Noname.LikeBuy(Condoms.TakeOut(2));

            //调用收银业务类
            CashierRegisterBIZ biz = new CashierRegisterBIZ(CashierMM ,crManchines);
            biz.AddQueue(Chunge);
            biz.AddQueue(Beianqi);
            biz.AddQueue(Noname);

            biz.CashierRegister();


        }
示例#3
0
 public CashierRegisterBIZ(Cashier cashier):this(cashier,cashier.UsingCashierRegister )
 {
     CashierManageBIZ biz = new CashierManageBIZ();
     if (!biz.TestAssignedCashier(cashier))
         throw new Exception("当前收银员未被指派,不能创建收银台。收银员名称:"+cashier.CashierName );
     
 }
示例#4
0
        private DateTime lastProcessTime;//上次处理的时间,避免超时无效客户的排队

        public CashierRegisterBIZ(Cashier cashier, CashierRegisterMachines crm)
        {
            this.CurrCashier = cashier;
            this.CurrCashier.UsingCashierRegister = crm; 
            this.CurrCRManchines = crm;
            customerQueue = new Queue<Customer>();
        }
示例#5
0
 /// <summary>
 /// 测试当前收银员是否已经分派到收银台
 /// </summary>
 /// <param name="cashier"></param>
 /// <returns></returns>
 public bool TestAssignedCashier(Cashier cashier)
 {
     foreach (Cashier c in AssignedCashier)
     {
         if (c.WorkNumber == cashier.WorkNumber)
         {
             cashier.UsingCashierRegister = c.UsingCashierRegister;
             return true;
         }
     }
     return false;
 }
示例#6
0
 /// <summary>
 /// 指派收银员到某个收银台(使用某个收银机)
 /// </summary>
 /// <param name="cashRegisterNo">收银机编号</param>
 /// <param name="cashier">收银员</param>
 /// <returns></returns>
 public bool AssignCashier(string cashRegisterNo,Cashier cashier)
 {
     //如果该收银机编号已经被使用,则不能再分配
     foreach (Cashier c in AssignedCashier)
     {
         if (c.UsingCashierRegister.CashRegisterNo  == cashRegisterNo)
             return false;
     }
     CashierRegisterMachines manchines = new CashierRegisterMachines() { CashRegisterNo = cashRegisterNo };
     cashier.UsingCashierRegister = manchines;
     AssignedCashier.Add(cashier);
     return true;
 }