Example #1
0
        public void InstantiateRowLengthDictionaries()
        {
            //starting point - based on the database order
            SeatType currentSeatType = SeatType.Upper;
            char     currentRow      = 'E';
            int      currentLength   = 0;

            //variables to keep hold of the next seat in the list values
            Seat     nextSeat;
            SeatType nextSeatType;
            char     nextSeatRow;
            int      nextSeatNumber;

            for (int i = listOfAllSeats.Count - 1; i >= 0; i--)
            {
                nextSeat       = listOfAllSeats[i];
                nextSeatType   = nextSeat.GetSeatType();
                nextSeatRow    = nextSeat.GetSeatRow();
                nextSeatNumber = nextSeat.GetSeatNumber();

                if (currentSeatType.Equals(nextSeatType))
                {
                    if (currentRow.Equals(nextSeatRow))
                    {
                        currentLength++;
                    }
                    else
                    {
                        RowLengthDictionariesSwitch(currentSeatType, currentRow, currentLength);
                        currentLength = 1;
                        currentRow    = nextSeatRow;
                    }
                    if (i == 1)
                    {
                        RowLengthDictionariesSwitch(currentSeatType, currentRow, currentLength);
                    }
                }
                else
                {
                    RowLengthDictionariesSwitch(currentSeatType, currentRow, currentLength);
                    currentLength   = 1;
                    currentRow      = nextSeatRow;
                    currentSeatType = nextSeatType;
                }
            }
        }