SWE/CS 332 In Class Exercise # 21

Name(s):
Another visit to the Stack class, this time from scratch. Create a generic, immutable class called IStack.
  1. Use Bloch's advice on lists vs. arrays. This will make your methods very simple to implement.
  2. Enforce the prohibition on overridable methods with a private constructor. You will need a static factory so clients can obtain an empty stack. (Defer the generics on this until the end; it can be a picky exercise.)
  3. Include a pushAll method with an appropriate parameter and signature.
  4. Include a popAll method with an appropriate parameter and signature. Note that the corresponding producer for popAll is simply the static factory you built earlier. Hence, just focus on the observer. Somewhat counterintuitively, this observer should have a void return type. The observation is returned through the parameter.
  5. Build some simple client code in a main method to exercise your stack.
Build this in an IDE so that the compiler can check your generics.