Esempio n. 1
0
        /// <summary>
        /// Method that returns turned floor for the elevator which are moving to the up side.
        /// </summary>
        /// <returns></returns>
        public Floor MaxTurnedPoint()
        {
            var maxQueue  = QueueOfRequests.FirstOrDefault();
            var maxInside = QueueFromInside.FirstOrDefault();

            switch (maxQueue)
            {
            case null when maxInside != null:
            {
                var maxFromInsideTemp = int.Parse(QueueFromInside.First().Id[5].ToString());

                foreach (var item in QueueFromInside)
                {
                    var tempItem = int.Parse(item.Id[5].ToString());
                    if (maxFromInsideTemp >= tempItem)
                    {
                        continue;
                    }
                    maxFromInsideTemp = tempItem;
                    maxInside         = item;
                }
                return(maxInside);
            }

            case null when QueueFromInside.Count == 0:
                return(null);
            }

            var maxFromQueue = int.Parse(QueueOfRequests.First().Id[5].ToString());

            foreach (var item in QueueOfRequests)
            {
                var tempItem = int.Parse(item.Id[5].ToString());

                if (maxFromQueue >= tempItem)
                {
                    continue;
                }
                maxFromQueue = tempItem;
                maxQueue     = item;
            }

            if (QueueFromInside.Count == 0)
            {
                return(maxQueue);
            }

            var maxFromInside = int.Parse(QueueFromInside.First().Id[5].ToString());

            foreach (var item in QueueFromInside)
            {
                var tempItem = int.Parse(item.Id[5].ToString());

                if (maxFromInside >= tempItem)
                {
                    continue;
                }
                maxFromInside = tempItem;
                maxInside     = item;
            }

            if (QueueOfRequests.Count == 0)
            {
                return(maxInside);
            }

            if (maxInside != null && maxQueue != null && maxQueue.Id[5] > maxInside.Id[5])
            {
                return(maxQueue);
            }

            return(maxInside);
        }
Esempio n. 2
0
        /// <summary>
        /// Method that returns turned floor for the elevator which are moving to the down side.
        /// </summary>
        /// <returns></returns>
        public Floor MinTurnedPoint()
        {
            var minQueue  = QueueOfRequests.FirstOrDefault();
            var minInside = QueueFromInside.FirstOrDefault();

            switch (minQueue)
            {
            case null when minInside != null:
            {
                var minFromInsideTemp = int.Parse(QueueFromInside.First().Id[5].ToString());

                foreach (var item in QueueFromInside)
                {
                    var tempItem = int.Parse(item.Id[5].ToString());
                    if (minFromInsideTemp <= tempItem)
                    {
                        continue;
                    }
                    minFromInsideTemp = tempItem;
                    minInside         = item;
                }
                return(minInside);
            }

            case null when QueueFromInside.Count == 0:
                return(null);
            }

            var minFromQueue = int.Parse(QueueOfRequests.First().Id[5].ToString());

            foreach (var item in QueueOfRequests)
            {
                var tempItem = int.Parse(item.Id[5].ToString());

                if (minFromQueue <= tempItem)
                {
                    continue;
                }
                minFromQueue = tempItem;
                minQueue     = item;
            }
            if (QueueFromInside.Count == 0)
            {
                return(minQueue);
            }

            var minFromInside = int.Parse(QueueFromInside.First().Id[5].ToString());

            foreach (var item in QueueFromInside)
            {
                var tempItem = int.Parse(item.Id[5].ToString());

                if (minFromInside <= tempItem)
                {
                    continue;
                }
                minFromInside = tempItem;
                minInside     = item;
            }

            if (QueueOfRequests.Count == 0)
            {
                return(minInside);
            }

            return(minInside != null && minQueue != null && (int)minQueue.Id[5] > (int)minInside.Id[5] ? minInside : minQueue);
        }