QueueOfTiles Constructor
This is a constructor, it is a method sharing the same name as the class but it has no return type. A constructor is the very first method that runs whenever an instance is created.
Code
public QueueOfTiles(int MaxSize)
{
this.MaxSize = MaxSize;
this.Rear = -1;
for (int Count = 0; Count < this.MaxSize; Count++)
{
Contents.Add("");
this.Add();
}
}
This is the constructor without any other code, it requires a int.
public QueueOfTiles(int MaxSize)
{
}
This sets the instance MaxSize to the passed in MaxSize.
this.MaxSize = MaxSize;
This sets the instace rear to -1.
this.Rear = -1;
This is a standard for loop that goes through until it has reached the MaxSize.
for (int Count = 0; Count < this.MaxSize; Count++)
{
}
This adds an empty string to the contents list and then calls the Add method to correct the rear pointer.
Contents.Add("");
this.Add();