Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java program In many hazardous operations where humans find it dangerous, and in these type of situations, we use robots to do the task. One

Java program

In many hazardous operations where humans find it dangerous, and in these type of situations, we use robots to do the task. One of the task the robot needs to do is to navigate to the target destination. And to do that, the robot is programmed with certain valid directions and the number of steps it can move in that direction.

Assuming, the robot can move in any one of the four valid directions (Forward (F), Back (B), Left(L), Right (R)) followed by the number of steps it can move in that direction. The number of steps it can take is between 1 to 99.

The robot needs to be programmed first with one of the valid four directions (F,B,L,R) and then followed by the number of steps.

Some examples of valid codes are

F4L1B3, R5F2, B7, L8F12R4B3, L1, R51

Some of the invalid codes are:

12, LR, L23J2, K3F5, R12, F6L327R12, B5R8L+, L4-R3

In this program assignment, 3 classes will be used. They are checkCode(String path), checkNavigate(int row, int col, String path), navigateRoute(int srow, int scol, int trow, tcol, String path), where the parameters are passed to the methods in the classes.

Class checkCode

A method in the class has input parameters (String path) and returns if the input code is valid(True) or invalid(False)

Class checkNavigate

A method in the class has input parameters (int row, int col, String path) and determines the number of steps it could take indicated by the path. Here as the robot navigates according to the direction given in the path, it will finally return the number of steps it took without going off the wall or hit an obstacle (wall). There is a possibility the robot may be stopped by an obstacle(wall) or going beyond the wall. If that happened, then the robot stops and returns the number of steps it took.

Int row, int col indicates the starting point of the grid. The path starts from (int row, int col).

Class navigateRoute.

A method In this class has input parameters (int srow, int scol, int trow, tcol, String path), and determines the number of steps a robot starting at position(srow, scol) takes to reach the target destination (trow, tcol) indicated by the given path. If the robot hits a wall(obstacle) along the path then it returns a value -1 and if it went off the wall, then the program returns -2. On the other, if it reaches not the target destination without hitting an obstacle(wall) or going beyond a wall, which implies the programmed path was incorrect, so in this case it returns 0. If it reaches the target destination as indicated by the path, then it returns 1, which indicates it was a successful operation.

Write a program to implement the above classes and methods for a floor plan of grid 30 x 30. There are four walls surrounding the boundaries of the floor plan, and the obstacles such as pillar, loose furniture found in the floor plan are also considered as a wall in that grid location. You are advised to placed the obstacles (wall) randomly in the floor plan which acts as a wall during the time the robot navigates using the path given as a parameter in the method.

image text in transcribed

30 1,30 30,30 1 1,1 1,30 1

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 An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

Summarize some human resource management training initiatives.

Answered: 1 week ago