Stack := Object clone do( newSlot("stack") newSlot("capacity", 10) init := method(stack = list) push := method(x, if(stack size + 1 > capacity, StackOverflowError raise("Stack is full.") ) stack push(x) ) top := method( if(stack size == 0, StackUnderflowError raise("Cannot call top on an empty stack.") ) stack last ) pop := method( if(stack size == 0, StackUnderflowError raise("Cannot call pop on an empty stack.") ) stack removeLast ) )