using System.Diagnostics;
namespace UnitTestProject1
private String[] stackArray;
private int topOfStack = -1;
public TheStack(int size)
stackArray = new String[size];
stackArray = Enumerable.Repeat<string>("-1", size).ToArray();
public void DisplayStack() {
Console.WriteLine("PEEK : top of stack is " + stackArray[topOfStack]);
return stackArray[topOfStack];
public void Push(string input)
if (topOfStack + 1 < stackSize)
stackArray[topOfStack] = input;
throw new StackOverflowException("stack full");
public void PushMany(string[] input)
stackArray[topOfStack] = "-1";
return stackArray[topOfStack--];
throw new StackOverflowException("stack empty");
public void PopMany(int size)
private string[] queueArray;
private int front, rear, numberOfItems = 0;
public TheQueue(int size)
queueArray = new String[size];
queueArray = Enumerable.Repeat<string>("-1", size).ToArray();
public void DisplayQueue()
Console.WriteLine("PEEK : the first element is " + queueArray[front]);
return queueArray[front];
public void Insert(string input)
if (numberOfItems + 1 <= queueSize)
queueArray[rear] = input;
throw new Exception("Queue is full");
public void PriorityInsert(string input)
for (i = numberOfItems - 1; i >= 0; i--)
if (string.Compare(input, queueArray[i]) > 0)
queueArray[i + 1] = queueArray[i];
queueArray[i + 1] = input;
public void InsertMany(string[] input)
queueArray[front] = "-1";
throw new Exception("Queue is empty");
public void RemoveMany(int size)
public void TestStackFunctions()
var test = new TestStack();
test.TestStackFunctions();