Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The current StackInterface has 5 methods; In addition to the 5 methods, A) I want you to add 2 additional methods as shown below: 1)

image text in transcribedimage text in transcribedimage text in transcribed

The current StackInterface has 5 methods; In addition to the 5 methods, A) I want you to add 2 additional methods as shown below: 1) firstDataEnteredis () : T This method returns the first element that was added to the stack, ie. It returns the bottom of the stack, without removing it : if stack is empty then it returns null. Example, If we add items to the stack in the following order push ("CSIS210"), push ("MATH201"), push ("CHEM115"), Push("CSIS330" ) then if we call firstDataEnteredIs () it would return CSIS210 and stack remains unchanged. 2) find (T) :boolean This method returns true if T is in the stack otherwise it returns false Example, If we add items to the stack in the following order push ("CSIS210"), push ("MATH201") , push ("CHEM115"), Push ("CSIS330" ) then if we call find ("PHYS116") it would return false and if we call find ("CHEM115") it would return true. B) I want you to modify the class LinkedStack and rename it to LinkedStack2 so its implements the 2 new methods added in StackInterface C) Write a main method in class LinedStack2 to make sure both new methods work as they are supposed to, ie create a stack, add data to it then call the method and print what it should return and what it actually returns. Test method firstDataEnteredIs returns the correct data when stack has data and when stack is emptyialso test f ind with argument that is in the stack and with an argument not in the stack

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

. What did you assume that your instructor did not say to youi>

Answered: 1 week ago