public MainWindow()
        {
            InitializeComponent();

            _supermarket = new SuperMarket();

            lv_items.ItemsSource              = _supermarket.SMStock;
            _supermarket.SMStock.ItemChanged += () => { lv_items.ItemsSource = _supermarket.SMStock.ToArray();
                                                        Console.Out.Flush(); };
        }
        private static void PrintStock(SuperMarket sm)
        {
            Console.WriteLine("---------------------");
            foreach (var a in sm.SMStock)
            {
                Console.WriteLine(a);
            }
            Console.WriteLine($"Profit:\t{sm.Profit}\nClashFlow:\t{sm.CashFlow}");
            Console.WriteLine($"Cust in Line:\t{sm.WaitingForCheckoutCustomers.Count}");
            long arrived = sm.CustomersArrived;

            Console.WriteLine($"Helped: {sm.CustomersHelped}, Arrived: {arrived}, In store {sm.WaitingForProductCustomers.Count}");
            Console.WriteLine($"Arrived per sec: {(arrived - prevCustArrived) *2}");
            prevCustArrived = arrived;
        }
        public static void Main(String[] args)
        {
            SuperMarket supermarket = new SuperMarket();

            //supermarket.SMStock.ItemChanged += () => {
            //    PrintStock(supermarket.SMStock, supermarket.Profit, supermarket.CashFlow);
            //};

            while (true)
            {
                Thread.Sleep(500);
                lock (supermarket)
                {
                    PrintStock(supermarket);
                }
            }
        }
Beispiel #4
0
 public Cashiere(SuperMarket superMarket)
 {
     this.superMarket = superMarket;
     timer            = new Timer(HelpCustomer, null, SuperMarket.Rand.Next(2000), 1000);
     //timer = new Timer(HelpCustomer, null, 1000, 1000);
 }
Beispiel #5
0
 public Chief(SuperMarket sm)
 {
     _superMarket = sm;
     timer        = new Timer(CheckStock, null, 200, 200);
 }