Ejemplo n.º 1
0
 private void CashDeskWork(CashDesk cashDesk, CancellationToken token)
 {
     while (!token.IsCancellationRequested)
     {
         if (cashDesk.Count > 0)
         {
             cashDesk.Dequeue();
             Thread.Sleep(CashDeskSpeed);
         }
     }
 }
Ejemplo n.º 2
0
 private void CashDeskWork(CashDesk cashDesk)
 {
     while (isWorking)
     {
         if (cashDesk.Count > 0)
         {
             cashDesk.Dequeue();
             Thread.Sleep(CashDeskDelay);
         }
     }
 }
Ejemplo n.º 3
0
 private void CashDeskWork(CashDesk cashDesk, int sleep)
 {
     while (isWorking)
     {
         if (cashDesk.Count > 0)
         {
             cashDesk.Dequeue();
             Thread.Sleep(sleep);
         }
     }
 }
Ejemplo n.º 4
0
        public ShopModel()
        {
            CashDesks = new List <CashDesk>();
            Sellers   = new Queue <Seller>();

            Generator.GetNewSellers(20);
            Generator.GetNewProducts(1000);

            foreach (var seller in Generator.Sellers)
            {
                Sellers.Enqueue(seller);
            }

            for (int i = 0; i < 3; i++)
            {
                var cashDesk = new CashDesk(CashDesks.Count + 1, Sellers.Dequeue(), null);
                CashDesks.Add(cashDesk);
            }
        }
Ejemplo n.º 5
0
        private void CreateCarts(int customerCounts)
        {
            while (isWorking)
            {
                List <Customer> customers = Generator.GetNewCustomers(customerCounts);

                foreach (Customer customer in customers)
                {
                    Cart cart = new Cart(customer);

                    foreach (Product product in Generator.GetRandomProduct(10, 30))
                    {
                        cart.Add(product);
                    }

                    CashDesk cashDesk = CashDesks[random.Next(CashDesks.Count)];
                    cashDesk.Enqueue(cart);
                }

                Thread.Sleep(CustomerSpeed);
            }
        }
Ejemplo n.º 6
0
        public CashBoxView(CashDesk cashDesk, int number, int x, int y)
        {
            this.cashDesk = cashDesk;

            Label               = new Label();
            NumericUpDown       = new NumericUpDown();
            ProgressBar         = new ProgressBar();
            LeaveCustomersCount = new Label();

            Label.AutoSize = true;
            Label.Location = new Point(x, y);
            Label.Name     = "label" + number;
            Label.Size     = new Size(35, 13);
            Label.TabIndex = number;
            Label.Text     = cashDesk.ToString();

            NumericUpDown.Location = new Point(x + 70, y);
            NumericUpDown.Name     = "numericUpDown" + number;
            NumericUpDown.Size     = new Size(120, 20);
            NumericUpDown.TabIndex = number;
            NumericUpDown.Maximum  = 10000000000000000;

            ProgressBar.Location = new Point(x + 250, y);
            ProgressBar.Maximum  = cashDesk.MaxQueueLenght;
            ProgressBar.Name     = "progressBar" + number;
            ProgressBar.Size     = new Size(100, 23);
            ProgressBar.TabIndex = number;
            ProgressBar.Value    = 1;

            LeaveCustomersCount.AutoSize = true;
            LeaveCustomersCount.Location = new Point(x + 400, y);
            LeaveCustomersCount.Name     = "label2" + number;
            LeaveCustomersCount.Size     = new Size(35, 13);
            LeaveCustomersCount.TabIndex = number;
            LeaveCustomersCount.Text     = "";

            cashDesk.CheckClosed += CashDesk_CheckClosed;
        }