Question: Develop a new class, called MyStackYourname, to implement, among others, key stack operations [push(e), pop(), peek(), size(), isEmpty(), toString()]we discussed in the class. Again, class

Develop a new class, called MyStackYourname, to implement, among others, key stack operations [push(e), pop(), peek(), size(), isEmpty(), toString()]we discussed in the class. Again, class Stack needs to be defined as generic stack with type so that we can create stack objects that can hold data of different types, such as integer stack, string stack, char stack, double stack, etc. You can inherits java.util.ArrayList or java.util.LinkedList to implement MyStackYourname. You can use an java.util.ArrayList or java.util.LinkedList as your classs member for data container. You can follow my implementation from the class lectures, but please write yourself. MyStackYourname Class must have these methods methodname(argument): returnType - isEmpty(): boolean Returns true if this stack is empty - size(): int Returns the number of elements in this stack - peek(): E Returns the top element in this stack - pop(): E Returns and removes the top element in this stack - push(E element): E Adds a new element to the top of this stack - toString(): String Returns the String with all elements in current stack // based on your choice, toString will return the String with all elements in order [top to bottom] or [bottom to top] You cannot change method names, return type and parameter types. To evaluate your Classs methods, the instructor will use another Test Program and will invoke your methods based on the class definition above. Next, develop a simple test program in a new class called TestStackYourname to test all stack methods(operation) listed above and defined in your class MyStackYourname. - This tester will not be graded if Part2/3/4 shows a successful result. - If Part2/3/4 isnt working correctly, the tester will be graded for extra partial points.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!