예제 #1
0
        /// <summary>
        /// Enqueues customer in Cashier's queue
        /// </summary>
        /// <param name="customer">Customer to wait in Cashier Queue</param>
        /// <returns>Processing time remaining from time of customer arrival</returns>
        public int EnqueueCustomer(Customer customer)
        {
            if (customer.ArrivalTime != _lastCalculationTime)
            {
                MoveClockForward(customer.ArrivalTime - _lastCalculationTime);
            }
            _customersToServe.AddLast(customer);
            _numCustomers++;

            return CalculateCurrentCompletionTime();
        }
예제 #2
0
        private bool EnqueueCustomer(Customer customer)
        {
            ICashier selectedCashier = customer.ChooseCashier(_cashiers);
            if (selectedCashier == null) return false;

            int cashierRemainingProcessingTime = selectedCashier.EnqueueCustomer(customer);
            if (_maxProcessingTimeFromStart == 0)
            {
                _maxProcessingTimeFromStart = customer.ArrivalTime + cashierRemainingProcessingTime;
            }
            else
            {
                if ((customer.ArrivalTime + cashierRemainingProcessingTime) > _maxProcessingTimeFromStart)
                {
                    _maxProcessingTimeFromStart = customer.ArrivalTime + cashierRemainingProcessingTime;
                }
            }
            return true;
        }