Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I did, did I? StackBox Implement our own stack class patterned after Java's Stack class. See slides in class for details. Start with a generic

image text in transcribedimage text in transcribedimage text in transcribed

I did, did I? StackBox Implement our own stack class patterned after Java's Stack class. See slides in class for details. Start with a generic class that uses an ArrayList for storage of the elements. public class StackBox ArrayList stack = new ArrayList(); (you may use an Array instead of the ArrayList if you like or you could use your ArrayBox instead of the ArrayList if you like. I think using Java's own ArrayList would be the easiest.) Part I: Part : Implement the following methods in StackBox: boolean empty() Tests if this stack is empty. E push(E item) Pushes an item onto the top of this stack. Returns item pushed. E pop() Removes the object at the top of this stack and returns that object as the value of this function. E peek() Looks at the object at the top of this stack without removing it from the stack. Refer to my slides in class for exact specifications details for each of these methods. Specifically, for full marks your StackBox must throw exceptions as described in their JavaDoc specification (again see class slides). Part II: Palindrome Part II: Palindrome Using your StackBox class, create a driver program that can determine if an input string provided by a user is a palindrome (spells the same forward as backward). Again, see class slides for discussion of this algorithm. For full marks, your solution must use your StackBox and it must use methods push, pop, and empty. Sample output: Enter a string> tenet The word tenet is a palindrome. Deliverables: Plai ir program and submit it below as per usual Grading: Defining StackBox as a generic class. [1 mark] Implementing the Stack methods as per their specification including throwing exceptions if specified. [ 4 marks ] Correctly working palindrome driver program using StackBox. [5 marks ]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data With Hadoop MapReduce A Classroom Approach

Authors: Rathinaraja Jeyaraj ,Ganeshkumar Pugalendhi ,Anand Paul

1st Edition

1774634848, 978-1774634844

Students also viewed these Databases questions

Question

=+b. The same businessman buys a New York apartment building.

Answered: 1 week ago

Question

6. Explain the power of labels.

Answered: 1 week ago

Question

5. Give examples of variations in contextual rules.

Answered: 1 week ago

Question

f. What stereotypes were reinforced in the commercials?

Answered: 1 week ago