Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a java program called lost puppy the includes create a java program called lost puppy that contains this information get Maze: Using the opened

Make a java program called lost puppy the includes image text in transcribed
create a java program called lost puppy that contains this information image text in transcribed
get Maze: Using the opened input Scanner, returns a 2D array containing the characters that make up the maze. If you apply the suggested method of continually reading and concatenating lines of input, while sequentially traversing a 2D array in row major order, you can use a separate index variable that is set to o before the loops begin and only increment after each character is copied from the String into the 2D array. getStartLocation And Direction: Once the array is filled, you need to locate the start position and the current direction the puppy is traveling when first entering the building. Depending on how you are solving this assignment, you will probably want to replace the 's' which indicates the start position, with the first asterisk'*'. The direction would be related to which side of the maze on which the 's' is found, i.e. If on row o, direction would be South (note, I avoid using down, as associated words such as left and right are only clearly defined based on the current direction the puppy is traveling) If on row 7 (Yes. This literal constant or magic number would be fine here as chess boards always have 8 rows and 8 columns, i.e. never a possibility or need to change it in the future. 7 is used as the indexing of arrays start at 0), then the direction is North If on col O(left side), the entry direction would be East. If on col 7 (right side), the entry direction would be West. You may also want to locate and return the Ending position (exit point containing the 'E') and replace the 'e' with a Up to you about everything the recursive method will need to know. However, since much of this data is primitive and methods can only return a single entity, you may need to consider creative means to pass so many primitives back to main so main can send them on to the actual recursive maze path solution method. One possibility is to store the row/column values in 2 element arrays. One for the start and one for the exit positions. Again, these are all matter you need to resolve and how you do it is up to you as long as you follow the basics: Do your own work See either me or the TA for assistance Decompose each operation/process into separate methods Never use class wide variables in an executable class (class that contains main), constants are fine can Move: Checks the row and column indices for a move about to be made for validity, i.e. indices are within acceptable bounds of the array and the location in the array contains a space or possibly the letter 'E' depending how you design your solution. Returns a Boolean. This will be used by the recursive maze solution method just prior to a desired move. doMaze (or some useful name): Recursive solution to navigating the paths found within a given maze. Overall, needs to be passed the various data (including the maze) needed and returns false for each recursive call unless the exit location is reached which should set the variable lised for the return statement to true space. Facts: The walls of the maze are indicated with X's The paths are indicated with spaces The entry or starting point is indicated with ans The exit point is indicated with an The input file is named "Marator" where the indicates a single romerice You can only read the input file once The number of columns is unknown, but can be determined from the string length of the first line The number of rows is unknown, but can be determined by counting the sumber of lines read . Once the input data is read and stored, you can then instantiate the 20 any of charlas a hint, you might want to readines into a string onto which you continually concatenate subsequent lines while counting each line read) Place each character from the stored input data into the 20 array Place an asterisk in each move location . Place a minus sign in cells where backtracking occurs The following processes should not appear in main, but decomposed into separate methods fonly suggesting method names and possible processing, but not requiring an eact naming or process get Mare: Using the opened input scanner, returns a 20 may containing the characters that make up the mazeif you apply the suggested method of continually reading and concatenating lines of input, while seguentially traversing a 20 array in row major order, you can use a separate Index variable that is set to before the loops begins and only increment after each character is copied from the String into the 2D array getStartlocation And Direction: Once the array is filed, you need to locate the start position and the current direction the poppy is traveling when first entering the building Depending on how you are solving this assignment you will probably want to replace the which indicates the start position, with the first asterisk. The direction would be related to which side of the maze on which the s' is found le If on rowo, direction would be South (note, I avoid using down, as associated words such as left and right are only clearly defined based on the current direction the poppy is traveling If on row 7 [Yes. This literal constant or magic number would be fine here as chessboards always have rows and 8 columns, le never a possibility or need to change in the future is used as the indexing of arrays start at then the direction is North on colofleft side, the entry direction would be East If on col 7 fright side the entry direction would be West You may also want to locate and return the Ending position text point containing the T) and replace the T with a Space Up to you about everything the recursive method will need to know. However, since much of this data is primitive and methods can only return a single entity, you may need to consider Creative means to pass so many primitives back to main so main can send them on to the actual recursive mare path solution method One possibility is to store the row/colurn values in 2 element arrays. One for the start and one for the position. Again, these are all matter you need to resolve and how you do it is up to you as long as you follow the basics Do your own work See either me or the TA for assistance Decompose each operation process into separate methods Never use class wide variables in an executable class class that contains man constants are fine can Move: Checks the row and column indices for a move about to be made for validity, indices are within acceptable bounds of the array and the location in the array contains a space or possibly the letter depending how you design your solution. Returns a Boolean. This will be used by the recursive mate solution method just prior to a desired move. do Mare for some useful name: Recursive solution to navigating the paths found within a piven maze Overall needs to be passed the various data including the maze needed and return false for each recursive calls the location is reached which should set the variable used for the return statement to true. Several approaches can be applied. However, fundamentally you need Base Case: The currently passed Row and Column values indicate the masses Sets the return valuable to true General (Recursive) Case: Based on the currently received row and composition, a move in 1 of 3 directions needs to be made (obviously a fourth move option would simply retum the puppy to the location from which he had just come which you want to avoid). However, before making the next move that move needs to be validated through a get Maze: Using the opened input Scanner, returns a 2D array containing the characters that make up the maze. If you apply the suggested method of continually reading and concatenating lines of input, while sequentially traversing a 2D array in row major order, you can use a separate index variable that is set to o before the loops begin and only increment after each character is copied from the String into the 2D array. getStartLocation And Direction: Once the array is filled, you need to locate the start position and the current direction the puppy is traveling when first entering the building. Depending on how you are solving this assignment, you will probably want to replace the 's' which indicates the start position, with the first asterisk'*'. The direction would be related to which side of the maze on which the 's' is found, i.e. If on row o, direction would be South (note, I avoid using down, as associated words such as left and right are only clearly defined based on the current direction the puppy is traveling) If on row 7 (Yes. This literal constant or magic number would be fine here as chess boards always have 8 rows and 8 columns, i.e. never a possibility or need to change it in the future. 7 is used as the indexing of arrays start at 0), then the direction is North If on col O(left side), the entry direction would be East. If on col 7 (right side), the entry direction would be West. You may also want to locate and return the Ending position (exit point containing the 'E') and replace the 'e' with a Up to you about everything the recursive method will need to know. However, since much of this data is primitive and methods can only return a single entity, you may need to consider creative means to pass so many primitives back to main so main can send them on to the actual recursive maze path solution method. One possibility is to store the row/column values in 2 element arrays. One for the start and one for the exit positions. Again, these are all matter you need to resolve and how you do it is up to you as long as you follow the basics: Do your own work See either me or the TA for assistance Decompose each operation/process into separate methods Never use class wide variables in an executable class (class that contains main), constants are fine can Move: Checks the row and column indices for a move about to be made for validity, i.e. indices are within acceptable bounds of the array and the location in the array contains a space or possibly the letter 'E' depending how you design your solution. Returns a Boolean. This will be used by the recursive maze solution method just prior to a desired move. doMaze (or some useful name): Recursive solution to navigating the paths found within a given maze. Overall, needs to be passed the various data (including the maze) needed and returns false for each recursive call unless the exit location is reached which should set the variable lised for the return statement to true space. Facts: The walls of the maze are indicated with X's The paths are indicated with spaces The entry or starting point is indicated with ans The exit point is indicated with an The input file is named "Marator" where the indicates a single romerice You can only read the input file once The number of columns is unknown, but can be determined from the string length of the first line The number of rows is unknown, but can be determined by counting the sumber of lines read . Once the input data is read and stored, you can then instantiate the 20 any of charlas a hint, you might want to readines into a string onto which you continually concatenate subsequent lines while counting each line read) Place each character from the stored input data into the 20 array Place an asterisk in each move location . Place a minus sign in cells where backtracking occurs The following processes should not appear in main, but decomposed into separate methods fonly suggesting method names and possible processing, but not requiring an eact naming or process get Mare: Using the opened input scanner, returns a 20 may containing the characters that make up the mazeif you apply the suggested method of continually reading and concatenating lines of input, while seguentially traversing a 20 array in row major order, you can use a separate Index variable that is set to before the loops begins and only increment after each character is copied from the String into the 2D array getStartlocation And Direction: Once the array is filed, you need to locate the start position and the current direction the poppy is traveling when first entering the building Depending on how you are solving this assignment you will probably want to replace the which indicates the start position, with the first asterisk. The direction would be related to which side of the maze on which the s' is found le If on rowo, direction would be South (note, I avoid using down, as associated words such as left and right are only clearly defined based on the current direction the poppy is traveling If on row 7 [Yes. This literal constant or magic number would be fine here as chessboards always have rows and 8 columns, le never a possibility or need to change in the future is used as the indexing of arrays start at then the direction is North on colofleft side, the entry direction would be East If on col 7 fright side the entry direction would be West You may also want to locate and return the Ending position text point containing the T) and replace the T with a Space Up to you about everything the recursive method will need to know. However, since much of this data is primitive and methods can only return a single entity, you may need to consider Creative means to pass so many primitives back to main so main can send them on to the actual recursive mare path solution method One possibility is to store the row/colurn values in 2 element arrays. One for the start and one for the position. Again, these are all matter you need to resolve and how you do it is up to you as long as you follow the basics Do your own work See either me or the TA for assistance Decompose each operation process into separate methods Never use class wide variables in an executable class class that contains man constants are fine can Move: Checks the row and column indices for a move about to be made for validity, indices are within acceptable bounds of the array and the location in the array contains a space or possibly the letter depending how you design your solution. Returns a Boolean. This will be used by the recursive mate solution method just prior to a desired move. do Mare for some useful name: Recursive solution to navigating the paths found within a piven maze Overall needs to be passed the various data including the maze needed and return false for each recursive calls the location is reached which should set the variable used for the return statement to true. Several approaches can be applied. However, fundamentally you need Base Case: The currently passed Row and Column values indicate the masses Sets the return valuable to true General (Recursive) Case: Based on the currently received row and composition, a move in 1 of 3 directions needs to be made (obviously a fourth move option would simply retum the puppy to the location from which he had just come which you want to avoid). However, before making the next move that move needs to be validated through a

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

PostgreSQL 10 High Performance Expert Techniques For Query Optimization High Availability And Efficient Database Maintenance

Authors: Ibrar Ahmed ,Gregory Smith ,Enrico Pirozzi

3rd Edition

1788474481, 978-1788474481

More Books

Students also viewed these Databases questions