Question
$50.00 1. Objectives You will write a program
- From Computer-Science: General-CS
- Closed, but you can still post tutorials
- Due on Dec. 01, 2011
- Asked on Nov. 30, 2011 at 08:54:43AM
Q:
1. Objectives
You will write a program that makes our BabyRobot start from the bottom left corner, visit every tile in a grid exactly once in a single continuous tour, i.e., without jumping to a non-adjacent tile, and come back to the bottom, left corner. Note that this task is not possible for certain types of grids, but it is for you to figure out which types.
You must use an Eclipse project setup that is the same as in HW2 or HW6. Make sure you review the use of the grid.jar and run configurations.
2. Program Input
The program will take one command-line argument (set in the run-configuration) exactly as you did in HW2 and HW6:
The name of the input grid file. You can assume that the input file exists.
3. Program Output
If you determine that the tiles in the input grid cannot be visited exactly once in a single tour, your program must print the following:
This tour cannot be completed.
If a tour is possible, your program will print the movements performed by the baby robot. Note that when you use the given code for the baby robot, you won't need to add any new print statements for reporting the movements. For example, if you call r.forward, where r is a BabyRobot, the forward method automatically prints the following:
Moving forward one tile.
4. How to Approach this Assignment
This is one problem where it will help you to sketch out the steps of the robot before you write out the solution as a Java program. Take various grids as examples and figure out how you would traverse the tiles yourself. Don't think about Java programming at this point. The focus here is on problem solving. When you work with examples, create several grids so that you can (1) identify which grids cannot be traversed as directed, and (2) for the grids that can be traversed, find the different ways of traversing them.
Once you understand how to traverse the tiles on the grid, write out the steps in the form of an algorithm (written in pseudo-code). Finally convert the algorithm into a Java program. Of course, the last two tasks may be performed in an iterative fashion if you realize that you have made a mistake.
5. Submission
You are provided with some skeleton code in a class called VisitAllTiles.java. Fill in the code between the lines that have the comments as follows:
// BEGIN NEW CODE HERE
// END NEW CODE HERE