Rex David wrote:Haha.. I dont see the error. What's happening , please explain. I'm new to this.
Rex David wrote:I will be able to post the entire requirements later once we submit our work for evaluation next week.
Agree. There is another thing: what are you going to return if somebody tries peek() on an empty Stack? Are you going to return null? But what if null is a permissible value on the stack? The user cannot distinguish an empty stack (error) from a null on top of the stack (normal occurrence). I shall have to formulate another rule about Exceptions. They are like dogs; they can smell fear. If you let them think they are scared of you, they will bite you, so you must show Exceptions who is boss. If you have an empty stack, then simply throw the Exception.Note the important tag in the documentation comments. Users must know about that behaviour. Note no throws clause because the exception involved is unchecked.
Junilu Lacar wrote:There really is no point to these kinds of throw/catch acrobatics . . .
You can thank my dental hygienist for my untimely aliveness. So tiny:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton