Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you help me solve the following using Java: Add the ability to explore multiple paths, especially ones that lead to a dead end. You

Can you help me solve the following using Java:
Add the ability to explore multiple paths, especially ones that lead to a dead end. You will have a program that can read a 2-dimensional cave layout from a file, search the layout to find a path to a mirror pool, then print the path to take.
This builds a set of classes to implement a search through a cave.
Directions - Write a class CaveExplorer, that has the following methods:
1. Extend your method solve to handle branching paths. In the example below, if the first move is West, then the explorer finds the mirror pool. But if the first move is South, the explorer hits a dead end. One trick to doing this is to use a stack. Whenever the explorer comes to a location with two or three possible moves, the moves should be put on a stack. If the explorer ever reaches a dead end without finding a mirror pool, then its time to pop the stack to make a move on a path not yet taken.
56
RRRRRR
R..S.R
R.R.RR
R.MRRR
RRRRRR
2. Extend your method getPath so that it shows exactly a path to the mirror pool, without showing any dead ends. This will require a little extra bookkeeping and coordination with the solve method.
3. main test your class by writing a main method that creates at least 4 CaveExplorer objects, prints the starting layout, the final layout, and the path taken, if it exists, for each one. Be sure to create test cases that require backtracking.
Included is the Original Code:
image text in transcribed

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

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions

Question

=+ 46-2 Discuss how an infant's brain begins processing memories.

Answered: 1 week ago