Write a class CaveExplorer, that has the following methods: 1. Constructor with no parameters. It should...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a class CaveExplorer, that has the following methods: 1. Constructor with no parameters. It should create the two-dimensional structure shown below, where the characters in the layout are 'R' for rock, for a clear path, 'M' for mirror pool, and 'S' for self. This constructor hardcodes the cave without reading from a file. RRRRRR R..SRR R.RRRR R.MRRR RRRRRR 2.toString - no parameters, returns a string (including new lines) showing the current state of the cave exploration. For the initial configuration, this string would be "RRRRRR\nR..SRR\nR.RRRR\nR.MRRR\nRRRRRR\n" 3. solve - no parameters, returns a boolean true if there is a path to the mirror pool, and false if there is not. This method is where you will spend some time figuring out the logic. Even though there is only one path, you still have to search in four different directions and make sure you don't get caught in an infinite loop. How you do this is up to you. 4. getPath - no parameters, returns a String showing the path taken to get to the mirror pool. In the example, this path would be the string of directions "wwsse" for West, West, South, South, East. The method should return the empty string if there is no path. 5. Constructor with one String parameter - the name of a text file with the cave layout. The file has a line with two integers, the number of rows and columns of the cave layout, followed by the layout itself. For example 56 RRRRRR R..SRR R.RRRR R.MRRR RRRRRR You will have to modify the text file with the cave data using your favorite editor. Your cave layout should contain a path requiring at least 4 moves in two different directions. There must be exactly one path through the cave, that is, from any location, there is only at most one location to move to next that hasn't already been visited. If you need help reading from a file, there are many resources on the web regarding using the Scanner class to read text data. A short one is the section on Scanners at https://math.hws.edu/javanotes/c11/s1.html 6. main - test your class by writing a main method that creates at least 2 CaveExplorer objects, solves each one, then prints the starting layout, the final layout, and the path taken, if it exists, for each one. Be sure to follow this order of operations. 7. Answer the following questions in your Word document: ⚫ Describe the state of your project, what works and what doesn't. Describe how you tested your program, including tests that made you rethink your code. Include the layout you used. ⚫ In a sentence or two, what did you learn? ⚫ In a sentence or two, what did you like about this project? ⚫ In a sentence or two, what did you find confusing or would like to see done differently regarding this project? ⚫ In a sentence or two, if you had another hour or two, what would you like to add to the project or how would you do things differently? Notes After your program is working for each step of the process, you should commit your changes to the repository. This allows you to go back to a previous working version in case you decide to throw out new code and try a different approach. Failure to commit after every step may result in a O for the assignment, regardless of the actual code. Use cave layouts that only have a single path from the starting position to the mirror pool, as in the example, or a single path that doesn't reach a mirror pool. Don't include any branching paths in your layouts and don't handle any branches in your code. Doing so will result in a significant loss of points. Write a class CaveExplorer, that has the following methods: 1. Constructor with no parameters. It should create the two-dimensional structure shown below, where the characters in the layout are 'R' for rock, for a clear path, 'M' for mirror pool, and 'S' for self. This constructor hardcodes the cave without reading from a file. RRRRRR R..SRR R.RRRR R.MRRR RRRRRR 2.toString - no parameters, returns a string (including new lines) showing the current state of the cave exploration. For the initial configuration, this string would be "RRRRRR\nR..SRR\nR.RRRR\nR.MRRR\nRRRRRR\n" 3. solve - no parameters, returns a boolean true if there is a path to the mirror pool, and false if there is not. This method is where you will spend some time figuring out the logic. Even though there is only one path, you still have to search in four different directions and make sure you don't get caught in an infinite loop. How you do this is up to you. 4. getPath - no parameters, returns a String showing the path taken to get to the mirror pool. In the example, this path would be the string of directions "wwsse" for West, West, South, South, East. The method should return the empty string if there is no path. 5. Constructor with one String parameter - the name of a text file with the cave layout. The file has a line with two integers, the number of rows and columns of the cave layout, followed by the layout itself. For example 56 RRRRRR R..SRR R.RRRR R.MRRR RRRRRR You will have to modify the text file with the cave data using your favorite editor. Your cave layout should contain a path requiring at least 4 moves in two different directions. There must be exactly one path through the cave, that is, from any location, there is only at most one location to move to next that hasn't already been visited. If you need help reading from a file, there are many resources on the web regarding using the Scanner class to read text data. A short one is the section on Scanners at https://math.hws.edu/javanotes/c11/s1.html 6. main - test your class by writing a main method that creates at least 2 CaveExplorer objects, solves each one, then prints the starting layout, the final layout, and the path taken, if it exists, for each one. Be sure to follow this order of operations. 7. Answer the following questions in your Word document: ⚫ Describe the state of your project, what works and what doesn't. Describe how you tested your program, including tests that made you rethink your code. Include the layout you used. ⚫ In a sentence or two, what did you learn? ⚫ In a sentence or two, what did you like about this project? ⚫ In a sentence or two, what did you find confusing or would like to see done differently regarding this project? ⚫ In a sentence or two, if you had another hour or two, what would you like to add to the project or how would you do things differently? Notes After your program is working for each step of the process, you should commit your changes to the repository. This allows you to go back to a previous working version in case you decide to throw out new code and try a different approach. Failure to commit after every step may result in a O for the assignment, regardless of the actual code. Use cave layouts that only have a single path from the starting position to the mirror pool, as in the example, or a single path that doesn't reach a mirror pool. Don't include any branching paths in your layouts and don't handle any branches in your code. Doing so will result in a significant loss of points. Write a class CaveExplorer, that has the following methods: 1. Constructor with no parameters. It should create the two-dimensional structure shown below, where the characters in the layout are 'R' for rock, for a clear path, 'M' for mirror pool, and 'S' for self. This constructor hardcodes the cave without reading from a file. RRRRRR R..SRR R.RRRR R.MRRR RRRRRR 2.toString - no parameters, returns a string (including new lines) showing the current state of the cave exploration. For the initial configuration, this string would be "RRRRRR\nR..SRR\nR.RRRR\nR.MRRR\nRRRRRR\n" 3. solve - no parameters, returns a boolean true if there is a path to the mirror pool, and false if there is not. This method is where you will spend some time figuring out the logic. Even though there is only one path, you still have to search in four different directions and make sure you don't get caught in an infinite loop. How you do this is up to you. 4. getPath - no parameters, returns a String showing the path taken to get to the mirror pool. In the example, this path would be the string of directions "wwsse" for West, West, South, South, East. The method should return the empty string if there is no path. 5. Constructor with one String parameter - the name of a text file with the cave layout. The file has a line with two integers, the number of rows and columns of the cave layout, followed by the layout itself. For example 56 RRRRRR R..SRR R.RRRR R.MRRR RRRRRR You will have to modify the text file with the cave data using your favorite editor. Your cave layout should contain a path requiring at least 4 moves in two different directions. There must be exactly one path through the cave, that is, from any location, there is only at most one location to move to next that hasn't already been visited. If you need help reading from a file, there are many resources on the web regarding using the Scanner class to read text data. A short one is the section on Scanners at https://math.hws.edu/javanotes/c11/s1.html 6. main - test your class by writing a main method that creates at least 2 CaveExplorer objects, solves each one, then prints the starting layout, the final layout, and the path taken, if it exists, for each one. Be sure to follow this order of operations. 7. Answer the following questions in your Word document: ⚫ Describe the state of your project, what works and what doesn't. Describe how you tested your program, including tests that made you rethink your code. Include the layout you used. ⚫ In a sentence or two, what did you learn? ⚫ In a sentence or two, what did you like about this project? ⚫ In a sentence or two, what did you find confusing or would like to see done differently regarding this project? ⚫ In a sentence or two, if you had another hour or two, what would you like to add to the project or how would you do things differently? Notes After your program is working for each step of the process, you should commit your changes to the repository. This allows you to go back to a previous working version in case you decide to throw out new code and try a different approach. Failure to commit after every step may result in a O for the assignment, regardless of the actual code. Use cave layouts that only have a single path from the starting position to the mirror pool, as in the example, or a single path that doesn't reach a mirror pool. Don't include any branching paths in your layouts and don't handle any branches in your code. Doing so will result in a significant loss of points.
Expert Answer:
Answer rating: 100% (QA)
Heres the Java class CaveExplorer with the requested methods and a main method for testing public class CaveExplorer private char cave private int row... View the full answer
Related Book For
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
(a) Show that the neutral pion cannot be composed solely of any pair of quarks in which one is an up quark (or an anti-up quark) and one is a down quark (or an anti-down quark). (b) According to...
-
Using the data presented for Pesci Ltd. in E17-4, prepare the operating activities section of the cash flow statement using the direct method. PESCI LTD Income Statement Year Ended November 30, 2017...
-
Tests show that, on average, the Li-ion Hitachi stick driver can drive 207 drywall screws on a single charge. Bob needs to drive 230 drywall screws. If the standard deviation is 14 screws, nd the...
-
Potassium atom 1 , with a mass of \(6.47 \times 10^{-26} \mathrm{~kg}\), has a speed of \(1.30 \times 10^{4} \mathrm{~m} / \mathrm{s}\). It collides with potassium atom 2 that is at rest, exciting...
-
When the equity method is applied, what disclosures should be made in the investors financial statements?
-
Sally earns $107,000 (Gross Salary) and is currently single with no dependents. Using the 2021 standard deduction of $12,550 determine her taxable income, marginal tax rate, due tax and average tax...
-
Propose a united-atom Molecular Mechanics Force Field (MMFF) for ONE (1) molecule that contains at least THREE (3) different organic elements with a total number of atoms in the range between 15 and...
-
- Write a program that takes in two matrixes - A and B. A user will enter the matrixes. Both matrixes are 3X3 Multiply matrix A by B. Use an multi-dimensional "array" Display the output in a matrix...
-
A refrigerator operating reversibly extracts 45.0 kJ of heat from a thermal reservoir and delivers 67.0 kJ as heat to a reservoir at 300 K. Calculate the temperature of the reservoir from which heat...
-
Glider A , traveling at 8 . 4 m / s on an air track, collides perfectly elastically with glider B traveling at 4 . 7 m / s in the same direction. The gliders are of equal mass. What is the final...
-
A circuit contains logic between two registers and is intended to run at 500MHz. The parameters for the circuit are: TLogic = 300 to 800ps TCIK-Q = 400 to 500ps TSetup = 300ps T Hold = 50ps Calculate...
-
Review the culture crisis at Basecamp https://www.theverge.com/2021/4/30/22412714/basecamp-employees-memo-policy-hansson-fried-controversy(Links to an external site.) AND...
-
Which surface has larger electric (1+1) flux? Why? Quiz 2 PHY (0& Spring 202U 1. which susfoce han Langer ekcric (I+1) flux ? why? 22 2. Which sunface has Langer electric flux?why? (I+) Os,
-
A manufacturer can sell product 1 at a profit of $20 per unit and product 2 at a profit of $40 per unit. Three units of raw material are needed to manufacture one unit of product 1, and six units of...
-
True or False: A method cannot return a reference to an object.
-
These are words that have a special meaning in the programming language. a. Punctuation b. Programmer-defined names c. Key words d. Operators
-
What is a result set?
-
On a rifle that has a telescopic sight, the telescope is usually not parallel to the barrel of the rifle. The angle the telescope makes with the barrel has to be adjusted for the distance to the...
-
A package is dropped from a helicopter traveling at \(15 \mathrm{~m} / \mathrm{s}\) (horizontally) at an altitude of \(200 \mathrm{~m}\), but the parachute attached to the package fails to open. (a)...
-
The velocity of an object is given in SI units by \(\vec{v}=\left(a t-b t^{2} ight) \hat{\imath}+c \hat{\jmath}\), with \(a=14 \mathrm{~m} / \mathrm{s}^{2}, b=10 \mathrm{~m} / \mathrm{s}^{3}\), and...
Study smarter with the SolutionInn App