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 -M ~mc38/man robots.
This gives your directions on how to play. ``-M
~mc38/man'' says ``Please look for the man page in the MC38
directory.''
- In a Unix shell window, type
~mc38/bin/robots.
- Read the manual page for robots again and give some thought to
how you would be designing your class to implement the robot.
- Check off: If you think you are familiar with the game, like
how to win, how a player lose and what every key does, ask to
get checked off.
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.