Exceptions, Stack

Idea: Make your own Exceptions and your own Stack.
Background:C#-note: p.51-55, MSVC#: Chap. 6

In this assignment, you have to create your own simple Stack type - class MyStack. A Stack is an ordered list of elements, but you can only access the top of the list. Push(int element) is a method that add an element to the top of the Stack and Pop is a method that removes an element from the top of the Stack.
The Stack have a given size (set by the constructor) and if a Push() is invoked on a full stack - it should throw an Exception: “MyStackIsFullException” and if a Pop() is invoked on an empty Stack it should throw an “MyStackIsEmptyException”

Implement the following Class-diagram:


 

And make a small test of the new class MyStack.
What happens if you call Pop() on an emtpy Stack or Push() on a full Stack? What about the Exceptions - were you forced to use try-catch?