QueueOfTiles Variables

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

The following code shows the declaration of the variables

Code

			private List<string> Contents = new List<string>();
			private int Rear;
			private int MaxSize;
			Random Rnd = new Random();

The code below declares a private list of strings called contents, this list is always generated as empty so it can be filled later. They use a list as they do not have a set length so they avoid stack overflows.

			private List<string> Contents = new List<string>();

This simply declares a private int called rear, it is going to be used to maintain a index for the back of the queue

			private int Rear;

This code defines the max size, this is safer then using an array as it will not cause a crash, however it means strange behaviour can get through.

			private int MaxSize;

This uses the random class that is accessed from

 using System.Random;

and creates a new instance that allows using the random number generation methods.

			Random Rnd = new Random();