INTRODUCTION TO
PROGRAMMING IN
C++
Mini-Lab:
Creating Fish in an Aquarium
Reading Interfaces and Writing Client Code
Alyce Brady
Kalamazoo College
Modify the Aquarium program.*
- Download the starting code files for the Aquarium Lab Series.
Compile and run the program. It doesn't do much yet, but you will be
adding several features to it over the next few labs to make it more
interesting. For now, it's just important to have something that
compiles and runs.
- Edit main.cpp to
modify the output statement to welcome users to the fish aquarium
program. Test the modified program.
- Research the partial AquaFish
interface to discover the simplest way to construct a fish.
Edit the main function to construct three fish variables.
- Research the display interface (in its
header file) to discover how
to display a fish.
Modify the main function to display the three fish you
constructed.
Using blank lines, separate this sequence of new statements, which
together perform a single function, from the existing code around
them. Add a single comment preceding them that describes the purpose
of the sequence. Test your modified program.
- Research the partial AquaFish
interface to discover how to make a fish move forward.
Add statements to the main function to move your three fish
one step forward. Then display the fish again.
Again, use blank lines and comments to separate functional units of code
from each other. Do this in the output as well, by adding a statement
to print a newline after the initial display of your fish.
Question: are the fish guaranteed to still be in the bounds of the
aquarium after the move forward? Why or why not?
- Update the program documentation at the top of the file to reflect
your modifications. Test your modified program.
You should see
the ID and location of each fish before and after the move.
Print and save your modifications.
*The Aquarium series of labs is loosely based on the
Advanced Placement Computer Science Marine
Biology Simulation Case Study,
available from the College Board.