Robots game
Your goal in this lab is to design and write a program to play
robots. This will be a graded lab which you'll work on
in groups of two. First, carefully plan out your program. Before doing
any programming, you should get your plan endorsed.
Play robots
The UNIX program robots predates the ubiquitousness of
graphical interfaces, so you have to play using keyboard input.
-
In Emacs, type
M-x man (for manual-page), and
enter robots. This gives your directions on how to play.
-
In a Unix shell window, type
/usr/games/robots.
Plan your program
Your goal is to write a program to play this game. Your game will use
a graphical interface, and need not include all the options in the
Unix version. You need not include a score file. But you will need
to decide on how the user will input decisions on where to move and
how to teleport.
Just as Horstmann plans out the Clock game in chapter 8, you should
plan out your program. You should have at least two classes
(probably more), and should plan on most of your code being in member
functions (as opposed to non-member functions).
Decide in advance what order you will write your classes and functions.
You don't need to program a whole class all at once. On the contrary,
I recommend coding part of it, testing a bit, and continuing. Plan
how you will test as you go along.
When designing your classes, you should:
- Make a stack of index cards, one for each Class.
- Each card has a list of member functions
- Each card has a list of instance (i.e., private) variables
- Number all member functions and procedures in the order you
intend to code and test them. Think about how you will test each
procedure, keeping in mind that your program is only partially
finished.
You must get your plan endorsed before continuing.
Write a working program
-
Write a program to play the game. Be sure that the code is clean, and
that all procedures are short and clear. (If you have time, feel free
to add whatever features you think would enhance or personalize your
program, but be sure your code is clean before embarking on ambitious
plans.)
- Rather than documenting each little member function, place
documentation for the class in the class's header file. So each class
declaration will have at least one header comment, and each non-member
function will have at least one header comment.
- Write a file called
README which describes the
rules for your game. In addition to features, include in the
README any bugs in your program. (You may assume that
the reader already knows how to play the built-in robots
game.)