Program #6: Stack


5/5 - (2 votes)

For this assignment, I want you to create and submit a file in which you
implement a stack class. This stack should ONLY have the following operations as defined
in our lectures.
1. Push: insert an item on top of the stack
2. Pop: delete an item from the top of the stack (and return it)
3. Peek: return (but do not delete) the item on top of the stack
4. Size: return the size of the stack
5. IsEmpty: return whether the stack is empty
6. IsFull: return whether the stack is full
7. Equals: compare two stacks
8. Add: concatenate two stacks
In addition, it should have a constructor, a copy constructor, and output capability i.e.
9. Stack()
10. Stack(Stack s)
11. String toString()
You are to build this stack ON TOP of your from Assignment #5. In fact, the
only member variable your Stack class will require is a generic list. To do this, make
sure that you have a copy of in the same folder as the file you’re
• For this assignment, you will be provided with two files:
{ contains the main function. You may NOT modify this file!
{ StackTest.out contains the output from my implementation of the stack. You
would be wise to ensure your output is EXACTLY the same (That includes
spacing and formatting).
• Recall that the only file you will submit is ( If you have implemented it
correctly, It should work with my version of
• Label the file by typing your name in a commented section at the top of the
file.• Compiling should automatically use your and
files (assuming they are in the same directory). After successful compilation, running
the produced executable file SHOULD produce output identical to StackTest.out.
• Feel free to redirect the output to a file of your choosing, and then compare the two files
(i.e. StackTest.out, and your output file) using the command prompt. For example,
once completed, the three commands below should NOT produce any output.
java StackTest myOutput
diff StackTest.out myOutput
java StackTest myOutput
fc StackTest.out myOutput
• Just so that we are on the same page, your stack should be oriented such that its top
is to the left i.e. the top of the stack is the left most item of the list.

PlaceholderProgram #6: Stack
Open chat
Need help?
Can we help?