CMPSCI 377: Operating Systems
Lab 1: Java Refresher
Due: Feb. 21, 2003 23:30
Purpose of Assignment
This assignment is intended to bring you up to speed on the
subset of Java you will need for this course (if you do not have it
yet). Anyone who cannot finish this assignment on time does not
have the necessary programming skills to complete this course successfully,
and should drop the course. Since the assignment is not really related
to operating systems, it will only count for 8% of your lab grade.
Resources
Programing for this lab may be done using the Computer Science
Ed Lab workstations.
The java compiler is envoked with the javac
command,
and the java virtual machine is started with the java
command.
Every student in CMPSCI377 has an edlab account; the
default username for the account is the first letter of your first name
followed by your last name; if your name is Allen Roberts, for example,
your username would be aroberts. The default password is your student
ID number. If you have trouble accessing your account, please ask the
monitor or someone in the CSCF office (in the CS Dept building). If you are logging in remotely, you should use elnux{0-34}
.
Where to do your work
For this lab, place your final submission in the following directory:
~/cs377/lab1
If your files are not located in the right place at the time of
submission, then your assignment will not be accepted. You may check
this by using the checkhw lab1
shell command (just as you
have done for lab 0).
The Problem
For lab 2, we will be solving a problem involving multiple,
coordinated robots (with which we will study threads and
synchronization). In short, there will be some set of robots of
various colors (red, green, and blue), and some set of goals (red,
green, blue, and black). The robots and goals will "live" on a
discrete grid of a specific size (think graph paper). Some grid squares
will be occupied by obstacles. In lab 2, the task will be for the individual
robots to move around on the grid and "eat" goals without running into
each other or any obstacles.
We will prepare for lab 2 here by performing two of the initial steps.
First, we will parse a file that contains information about where
the robots, goals, and obstacles are located. This file name will
be specified as the first command-line parameter. Second, we will
display a map of this world within a window.
Here is one example of a map file.
grid_size:row=10,col=10
1111111111
1000000001
1000000001
1000000001
1000011111
1000000001
1000000001
1000000001
1000000001
1111111111
num_robots=2
robot:row=2,col=2,r
robot:row=4,col=3,g
num_goals=3
goal:row=8,col=8,r
goal:row=4,col=2,g
goal:row=3,col=4,k
The semantics of this file are:
- The first line specifies the size of the grid (ROW, COL), e.g.,row=10,col=10 mean there are 10 rows and 10 columns in the grid. Note that the first Row(0) and Col(0) correspond to the top-left grid square of the world.
- There are ROW lines specifying the obstacles for each grid cell (1 means it is an obstacle; 0 otherwise).
- There is a line specifying the number of robots (e.g., num_robots=2).
- N lines specify the initial position and color
of the robots (ROW, COL, r/g/b), e.g., robot:row=2,col=2,r (red/green/blue).
- There is a line specifying the number of goals (e.g.,num_goals=3 ).
- M lines specify the position and color of the goals (ROW, COL, r/g/b/k) (k corresponds to black).
Your program must parse this file and place the information into an
appropriately-designed data structure. Your program should detect
and trap any errors that might exist in the file and display an
appropriate error message. Possible errors include:
- The corresponding ROW lines and COL lines are not compatible
with the sizes specified.
- The row and column of a Robot or an Obstacle are beyond the world border.
The output is a map of the grid that shows the obstacles, robots, and goals.
Here is an example that corresponds to the map file above:
Here, goals are shown as triangles and robots are shown as "Pac-Men".
In your implementation, these may be drawn in any way you like.
What to Hand In
Everyone must hand in their own work for this lab (in later labs,
you will be able to work in pairs).
Place in your Hand-In directory the following:
- An appropriately documented java source file (e.g., "lab1.java")
- An executable that you have compiled for and tested on the elnux
system (if we cannot execute your program, then we cannot give you correctness points). We will test this executable using shell
commands similar to the following: "
java lab1 map1.txt
"
- A "lab1.txt" file (raw ASCII format) that contains:
- Your name
- Your UID
- The name of your executable
We will test your program with a variety of maps, including:
Your program should produce an appropriate map for the first three
files and appropriate error messages for the last five files.
Grading
This lab is worth 8% of your lab grade.
This grade will depend on:
- Program Design (including data structures)/Implementation : 40%
- Correctness: 40%
- Documentation: 20%
Some Hints
This page is online at http://www-all.cs.umass.edu/~fagg/classes/377/labs/lab1/index.html
Andrew H. Fagg