Add

From TRCCompSci - AQA Computer Science
Revision as of 14:45, 14 November 2017 by Meep (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
            public void Add()
            {
                int RandNo = 0;
                if (Rear < MaxSize - 1)
                {
                    RandNo = Rnd.Next(0, 26);
                    Rear++;
                    Contents[Rear] = Convert.ToChar(65 + RandNo).ToString();
                }
            }


Generates a random number and adds it on to the queue before adding one to 'Rear'. The if loop finishes once the 'Rear' becomes equal to 'maxsize' minus 1. Note if the queue is full then then this method essentially does nothing.