Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.ArrayList; public class Maze { private char[][] cells; /** Constructs a maze from a string describing its contents. @param contents a string consisting of

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

import java.util.ArrayList; public class Maze { private char[][] cells; /** Constructs a maze from a string describing its contents. @param contents a string consisting of *, spaces, and newlines terminating the rows. */ public Maze(String contents) { int rows = 0; int columns = 0; int currentLength = 0; for (int i = 0; i

public ArrayList emptyNeighbors(Location loc) { ArrayList result = new ArrayList(); result.add(new Location(loc.getRow(), loc.getColumn() - 1)); result.add(new Location(loc.getRow(), loc.getColumn() + 1)); result.add(new Location(loc.getRow() - 1, loc.getColumn())); result.add(new Location(loc.getRow() + 1, loc.getColumn()));

for (int i = result.size() - 1; i >= 0; i--) { if (!isEmpty(result.get(i))) result.remove(i); } return result; }

/** Checks whether a location is an exit. @param loc the location @return true if the location is an exit */ public boolean isExit(Location loc) { /*-----IMPLEMENT THIS-----*/ return false; }

/** Checks whether a location is within the maze. @param loc the location @return true if the location is valid */ public boolean isValid(Location loc) { /*-----IMPLEMENT THIS-----*/ return false; }

/** Checks whether a location is within the maze and not a wall. @param loc the location @return true if the location is empty */ public boolean isEmpty(Location loc) { /*-----IMPLEMENT THIS-----*/ return false; } }

A location in a maze public class Location private int row; private int column; Constructs a location @param row the row @param column the column public Location(int row, int column) IMPLEMENT THIS Gets the row of this location @return the row public int getRow() IMPLEMENT THIS return 10; Gets the column of this location @return the column public int getColumn() IMPLEMENT THIS return 10; public String toString) row + ","+ column ")" public boolean equals (Object otherObject) Location other = (Location) otherObject; IMPLEMENT THIS* return false; A location in a maze public class Location private int row; private int column; Constructs a location @param row the row @param column the column public Location(int row, int column) IMPLEMENT THIS Gets the row of this location @return the row public int getRow() IMPLEMENT THIS return 10; Gets the column of this location @return the column public int getColumn() IMPLEMENT THIS return 10; public String toString) row + ","+ column ")" public boolean equals (Object otherObject) Location other = (Location) otherObject; IMPLEMENT THIS* return false

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

ISBN: 1285427106, 978-1285427102

More Books

Students also viewed these Databases questions