Note: no late submissions will be accepted for this assignment
This two-part assignment involves representing a grid that contains rectangular obstacles, and navigating a robot around the grid. For the first part, you will work in a two-person team (with partner assigned by the instructor). This part will be graded in a face-to-face meeting with the instructor. The second part will build upon the team-developed code and must be completed independently, with no outside consultation (other than with the instructor, of course).
The purpose of this first assignment is to refamiliarize you with Java programming and identify any holes in your knowledge/skills. We will be reviewing concepts from CSC222 in the first week of class, and students are encouraged to meet with the instructor to go over any unclear material. Since this assignment is intended as a review, no late submissions (for either part) will be accepted.
Partners for Part 1 Emily Baranowski Patrick Dougherty Logan Bell Ruby Labausa Mark Burgess Lauren Williams Austin Fillipi Stephen Yang Toria Johnson Tomoki Kyotani Bradley Koenen Matthew Mordeson Sam Koshy Dom Theis Victoria Lo Sindhuja Suresh Toby Smith Blair Wallace
For the first part of this assignment, your program should read in grid information from a text file and be able to display and access that grid. The first line in the file will contain two integers, representing the number of rows and columns (respectively) in the grid. Each subsequent line in the file contains four integers that identify a rectangular obstacle. The first two numbers specify the row and column (respectively) of the upper-left corner of the obstacle; the last two numbers specify the row and column of the bottom-right corner. Row and column numbers are assumed to start at 1. You may assume that obstacles are fully contained in the grid (i.e., you will never encounter an obstacle that extends off the grid).
For example, the file
robo1.txt on the left represents the 8x12 grid drawn on the right:
8 12 +------------+ 2 2 3 4 | * | 5 5 5 5 | *** * | 7 7 8 12 | *** * | 1 10 4 10 | * | | * | | | | ******| | ******| +------------+
After reading in the file contents, your program should display the grid in the exact format shown above, with asterisks for obstacles and a frame around the grid. Your program should also repeatedly prompt the user for a row and column number, and display whether that row/column is off the board, within an obstacle, or vacant within the grid. For example:
Please enter the grid file name: robo1.txt +------------+ | * | | *** * | | *** * | | * | | * | | | | ******| | ******| +------------+ Enter a row and column to check (zeros to exit): 10 8 (10, 8) IS OUTSIDE THE GRID Enter a row and column to check (zeros to exit): 3 3 (3, 3) IS WITHIN AN OBSTACLE Enter a row and column to check (zeros to exit): 4 3 (4, 3) IS VACANT IN THE GRID Enter a row and column to check (zeros to exit): 0 0 DONE
For the second part of this assignment, you will independently modify your code from Part 1 to simulate the controlled movements of a robot in the grid. Your program will repeatedly prompt the user for the starting position of a robot, followed by a sequence of moves within the grid (using the characters '>', '<', '^', and 'v' to denote directions). Your program must simulate the movements of the robot and identify whether it leaves the grid, crashes into an obstacle, or ends up unscathed on the grid. Also, to help in visualizing the grid, you should add labels to the rows and columns. If a row or column number has more than one digit, only the last digit should be displayed in the labels. For example:
Please enter the grid file name: robo1.txt 123456789012 +------------+ 1| * | 2| *** * | 3| *** * | 4| * | 5| * | 6| | 7| ******| 8| ******| +------------+ Enter the start row and col (zeros to end) and moves: 1 3 >>>vv<v ROBOT ENDS UP AT (4,5) Enter the start row and col (zeros to end) and moves: 7 6 >v>^^ START POSITION IS WITHIN AN OBSTACLE Enter the start row and col (zeros to end) and moves: 6 6 >v>^^ ROBOT CRASHES INTO AN OBSTACLE AT (7,7) Enter the start row and col (zeros to end) and moves: 6 6 >^^<vv ROBOT ENDS UP AT (6,6) Enter the start row and col (zeros to end) and moves: 6 2 <<<< ROBOT LEAVES THE GRID AT (6,0) Enter the start row and col (zeros to end) and moves: 0 0 DONE
You must demonstrate good programming style when completing both parts of this assignment,
including the appropriate use of Javadoc-style comments for all classes and
methds. The javadoc comment at the top of each class must contain a description of the class, the author (using
@author), and date (using
@version). Each method must have a javadoc comment that describes its overall behavior, each parameter (using
@param), and the return value (using
@return) if applicable.