Carey Brown wrote:--or--
You could implement equals() to internally access object
Stephan van Hulst wrote:Hugh, don't use names like Base for generic type parameters. Use single capital letters, such as T.
Hugh Winn wrote:Hello,
I am supposed to compare the top two elements without changing the nature of the stack, i.e I am not supposed to use peek(), pop(), or push() as the way we implement those methods in class will change the date structures. We can define stack differently and it all depends on how we use it, so the method of implementation is different. This is what I think. Thank you for sharing your thoughts.
Junilu Lacar wrote:As I said before, a Stack is associated with a specific set of concepts and abstractions. To add a method like areTheyEquals() that looks at TWO elements of the stack breaks away from the normal concepts and abstractions of a Stack. The whole point of a Stack is that you can deal directly ONLY with the top item. If you start looking at things beneath the top item, then you're not treating your data structure like a Stack anymore. You are, in fact, misusing and corrupting the idea of a Stack. So, in my opinion, this exercise is flawed at a very deep conceptual level. It is not a good exercise to use to evaluate whether a student understands what a Stack is.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:what is wrong by adding some utility methods, even if they make use of the internal structure?
There are three kinds of actuaries: those who can count, and those who can't.
Don't take criticism personally. When I make criticisms about the code and design, I'm not saying YOU are stupid. I'm saying that the code/design, as it has been written, is flawed, and yes, sometimes, it's pretty stupid. The only time the flaw or stupidity reflects on the author is when the author doesn't want to accept reasonable criticism and insists that they are correct. That means they are not willing to learn. When you are unwilling to learn and improve, THAT is what makes YOU stupid.
I was born with webbed fish toes. This tiny ad is my only friend:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|