Answered step by step
Verified Expert Solution
Question
1 Approved Answer
GETTING STARTED: We will not use any pre-defined data structures provided by Java or any other source. You should NOT use the Stack class from
GETTING STARTED: We will not use any pre-defined data structures provided by Java or any other source. You should NOT use the Stack class from the Java standard library for instance. You must implement a custom version of a stack from scratch. Note that this also means you may NOT use an ArrayList as part of your stack implementation 1. CREATING A STACK ADT Create a stack abstract data type called StackADT which declares the following methods. Note that StackADT is a generic interface using the type variable E 1 public void pushCE item); // adds a new item to the top of the stack 3 public E popO throws EmptyStackException; 77 removes the top item from the stack and returns it 5 public E peekO throws EmptyStackException; I/ returns the top item from the stack without removing it 7 public boolean isE // returns true if the stack is otherwise returns false 2. CREATING A STACK IMPLEMENTATION CLASS Create a class named MazeRunnerStack which implements StacKADT-Position>. It should throw an EmptyStackException if you attempt to pop or peek on an empty stack, and should throw an llegalArgumentException if you attempt to push a null item onto the stack. It should not otherwise throw any exceptions. Your stack implementation may use arrays, and may use package-visibility helper classes that you write for yourself. DO NOT USE JAVAS ARRAYLIST To support your MazeRunnerStack, you will need to import the EmptyStackException class. This is an unchecked exception. You will also need a helper class called Position consisting of the following 1 class Position t int col; int row Position int row, int col) this.col-col; this.row-row; 6 8 boolean equals(Position other) 10 return this.colother.col&&this.row-other.row Note that Position is neither private nor public. It has package visibility, meaning it can be used by any GETTING STARTED: We will not use any pre-defined data structures provided by Java or any other source. You should NOT use the Stack class from the Java standard library for instance. You must implement a custom version of a stack from scratch. Note that this also means you may NOT use an ArrayList as part of your stack implementation 1. CREATING A STACK ADT Create a stack abstract data type called StackADT which declares the following methods. Note that StackADT is a generic interface using the type variable E 1 public void pushCE item); // adds a new item to the top of the stack 3 public E popO throws EmptyStackException; 77 removes the top item from the stack and returns it 5 public E peekO throws EmptyStackException; I/ returns the top item from the stack without removing it 7 public boolean isE // returns true if the stack is otherwise returns false 2. CREATING A STACK IMPLEMENTATION CLASS Create a class named MazeRunnerStack which implements StacKADT-Position>. It should throw an EmptyStackException if you attempt to pop or peek on an empty stack, and should throw an llegalArgumentException if you attempt to push a null item onto the stack. It should not otherwise throw any exceptions. Your stack implementation may use arrays, and may use package-visibility helper classes that you write for yourself. DO NOT USE JAVAS ARRAYLIST To support your MazeRunnerStack, you will need to import the EmptyStackException class. This is an unchecked exception. You will also need a helper class called Position consisting of the following 1 class Position t int col; int row Position int row, int col) this.col-col; this.row-row; 6 8 boolean equals(Position other) 10 return this.colother.col&&this.row-other.row Note that Position is neither private nor public. It has package visibility, meaning it can be used by any
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