Question: 1.3 Create a new class DynamicArrayStack Modify the class ArrayStack to use a dynamic array. This new class DynamicArrayStack has a constant DEFAULT INC with



1.3 Create a new class DynamicArrayStack Modify the class ArrayStack to use a dynamic array. This new class DynamicArrayStack has a constant DEFAULT INC with the value 25. The constructor takes an argument capacity which is the initial size of the array, but it must always initialize with a minimum of DEFAULT_INC (25). It has a getter, getCapacity0, that returns an integer which is the length of the array. When the array becomes full, a new array is created with size DEFAULT INC more than the previous array and then filled with the elements from the previous array. Similarly, when the array has DEFAULT INC elements less than its capacity, it needs to be automatically reduced in size. Make the necessary changes, particularly in pop, push and clear, and in the constructor (recall, the minimal size of an array is DEFAULT INC) File: . DynamicArrayStack.java public class DynamicArraystack
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
