Answered step by step
Verified Expert Solution
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 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:
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.
RRRRRR
RSR
RRRR
RMRRR
RRRRRR
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.
main test your class by writing a main method that creates at least 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:
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