Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise 3 - Implementing a Stack 1. Open the StackADT interface. Examine the file and notice how there are method stubs that specify the required
Exercise 3 - Implementing a Stack 1. Open the StackADT interface. Examine the file and notice how there are method stubs that specify the required method signatures without implementing the methods. Any time we create a class that implements an interface, it must include all the methods defined in the interface. We will look at different implementations of this StackADT interface. 2. Open ArrayStack.java which is partially implemented but some methods are not included. Notice there is a compiler error at the top. Click on the little red X to see what the error is. What is the suggested resolution? Write this information in AnswersLab6.txt. 3. Examine the code that is provided. Compare the methods that are provided to the list of method stubs in the StackADT interface. Determine which methods need to be added to this file to satisfy the compiler. Which method exists in ArrayStack that is not included in the StackADT? Should this method be added as a stub in to the StackADT? Write your answer in AnswersLab6.txt. 4. Implement the 4 remaining methods in ArrayStack that have not been provided. Do not change any of the code that was provided to you. 5. Open LinkedStack.java which is partially implemented but some methods are not included. Notice there is NOT a compiler error at the top even though some of the methods are not implemented. Why does this class not show any compiler errors? Write this information in AnswersLab6.txt. 6. Complete the 3 remaining methods in LinkedStack. Do not change any of the code that was provided to you (other than the default return statements in those 3 methods). a. Note: in this class, we do not have an instance variable for the node count. In the LinkedStack implementation we discussed in lecture, there was a count variable. This is an implementation choice and for this lab we have made the choice to implement the class without such an instance variable
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started