Question: (JAVA - DATA STRUCTURES) PLEASE, DO NOT AVOID MY QUESTION. THIS IS THE THIRD TIME I POST THIS QUESTION AND NOBODY WANTS TO HELP ME.

(JAVA - DATA STRUCTURES) PLEASE, DO NOT AVOID MY QUESTION. THIS IS THE THIRD TIME I POST THIS QUESTION AND NOBODY WANTS TO HELP ME.

The code that you write for this assignment will build on top of two ADTs (List and Stack) and their implementations. Recall that the way Java has dealt with Stacks is rather odd: Stack is a class, rather than an interface, and the documentation recommends that you use a Deque instead. Rather than using Java's built in Stack methods, I've provided you with a Stack interface (Stack.java) and an implementation of a Stack (MysteryStackImplementation.class). The implementation of stack is just a class file, because you don't need to see how it is implemented in order to use it. For this assignment, you must use the Stack interface and implementation that I have providedyou may not use the built in Java Stack or Deque.

PART1: https://media.cheggcdn.com/media/7f3/7f3d633a-0346-4da2-b9c7-7bb7d4e597be/phpl45l64

PART2: https://media.cheggcdn.com/media/9a0/9a0f8655-7c9b-4e10-a838-cc3ee1a3f27d/php57fBqX

PART3: https://media.cheggcdn.com/media/2bc/2bc48486-d130-4a63-b575-a43f0d4c7d32/phpuuSnpE

PART4: https://media.cheggcdn.com/media/a61/a6163e13-ff4c-4cd1-882f-8d8d0e165535/phpZeWE8L

PART5: https://media.cheggcdn.com/media/2cc/2cc35de9-02e0-432c-9ff5-471c3008e78d/phpdRacUe

Maze.java

https://media.cheggcdn.com/media/4fa/4fafd055-dcfc-4753-ae59-510e00c06158/phpJguJLx

MazeSquare.java

/** * MazeSquare represents a single square within a Maze. * @author Anna Rafferty */ public class MazeSquare { //Wall variables private boolean hasTopWall = false; private boolean hasRightWall = false; //Location of this square in a larger maze. private int row; private int col; /** * Constructs a new maze square with walls as configured by * descriptor (7 = top and right, | is just right, _ is just * top, and * is neither top nor right) and located at the * given row and column. */ public MazeSquare(char descriptor, int row, int col) { this.row = row; this.col = col; if(descriptor == '7') { hasTopWall = true; hasRightWall = true; } else if(descriptor == '|') { hasTopWall = false; hasRightWall = true; } else if(descriptor == '_') { hasTopWall = true; hasRightWall = false; } else if(descriptor == '*') { hasTopWall = false; hasRightWall = false; } else { hasTopWall = false; hasRightWall = false; System.err.println("Unrecognized character for MazeSquare description: " + descriptor); } } /** * Returns true if this square has a top wall. */ public boolean hasTopWall() { return hasTopWall; } /** * Returns true if this square has a right wall. */ public boolean hasRightWall() { return hasRightWall; } /** * Returns the row this square is in. */ public int getRow() { return row; } /** * Returns the column this square is in. */ public int getColumn() { return col; } /** * Returns true if c is a valid identifier for a maze square */ public static boolean isAllowedCharacter(char c) { return c=='*' || c=='_' || c=='|' || c=='7'; } }

Stack.java

/** * An interface for the Stack ADT, adapted from Frank Carrano. * @author Jadrian Miles * @author Anna Rafferty */ public interface Stack { /** * Adds an item to the top of this stack. * @param item The item to add. */ public void push(T item); /** * Removes and returns the item from the top of this stack. * @return the item at the top of the stack. Throws an empty * stack exception if empty. */ public T pop(); /** * Returns the item on top of the stack, without removing it. * @return the item at the top of the stack. Throws an empty * stack exception if empty. */ public T peek(); /** * Returns whether the stack is empty. * @return true if the stack is empty; false otherwise */ public boolean isEmpty(); /** * Removes all items from the stack. */ public void clear(); }

REQUIREMENTS

  • Correct command-line syntax and behavior (two different possible usages)
  • load method returns true and false based on whether the maze file is properly formatted, and after load is called, the squares of the maze are stored in some way
  • getSolution returns a stack of maze squares containing a solution (or an empty stack if no solution is possible

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!