Modify the Stack class as follows:
stack.cs
using System;
/**
* An array implementation of a generic last-in first-out (LIFO)
* data structure.
*/
public class Stack< T > {
T[] contents;
int top;
/**
* Creates an empty stack of maximum size n.
*/
public Stack(int n) {
contents = new T[n];
top = -1;
}
/**
* Indicates whether the stack is empty.
*/
public bool Empty {
get => top == -1;
}
/**
* Adds an item to the top of the stack.
* @param The item to add.
* @throws InvalidOperationException if the stack is full.
*/
public void Push(T item) {
if (top == contents.Length - 1) {
throw new InvalidOperationException("Stack Overflow");
}
else {
contents[++top] = item;
}
}
/**
* Removes and returns the item from the top of the stack.
* @returns The top item.
* @throws InvalidOperationException if the stack is empty.
*/
public T Pop() {
if (top == -1) {
throw new InvalidOperationException("Empty Stack");
}
else {
return contents[top--];
}
}
}