The goals of this assignment are to:
Imagine a maze with a robot in it. The maze is arranged in a square grid of infinite size in both directions (although you can assume that an
int is large
enough to store the largest coordinate in our grid).
As an example, here's a picture of a 5x5 square grid maze. The robot is indicated by
 and the gold coin is
+--+--+--+--+--+ | | | | | | +--+--+--+--+--+ | | | | |()| +--+--+--+--+--+ | | | | | | +--+--+--+--+--+ | || | | | +--+--+--+--+--+ | | | | | | +--+--+--+--+--+In addition to your robot, there is also a gold coin in the maze. The object of the game is for the robot to find the gold coin. In this illustration, the robot would travel 3 steps to the left and 2 steps up to reach the gold coin.
You have to write a program that will take as input from the command line two pairs of coordinates: the location of the robot and the location of the gold coin. These must be whole numbers.
Your program has to do the following:
You can assume that the grid squares are numbered like a Cartesian (X-Y) graph, with positive X going horizontally to the right and positive Y going vertically upwards. Input coordinates can be negative, but they must be whole numbers. The output distance must be positive and must be expressed in whole numbers.
Below is a sample run for two cases. The unix command line is highlighted in bold font.
unix$ java hw2eis2003 8 9 1 7 robot is at position (8,9) coin is at position (1,7) robot travels 7 steps to the left robot travels 2 steps down robot travels a greater distance horizontally than vertically unix$ java hw2eis2003 8 9 8 1 robot is at position (8,9) coin is at position (8,1) robot does not travel horizontally robot travels 8 steps down robot travels a greater distance vertically than horizontally
Your source code (i.e., your
.java file) but be neat and
You must have a header comment and you should comment the end of each
block (i.e., each
Follow the submission instructions carefully!!! If you don't, human intervention will be required to fix your mistakes, and you will lose 1 point.
This assignment is worth 7 points (out of 100 for the semester). Distribution of points is: