Previous Exercise |
Next Exercise |
Solution |
Lecture |
Top Level
Context
We now have three classes of our monopoly game. Two classes reflecting
real components of the game, and one base class from which they are
derived. This is often expressed in a class hierarchy
diagram.
Base
|___Account
|___Dice
The Base class represents our general requirements we have
for all objects in our monopoly game. An Account
is a monopoly object. The Dice class is a
monopoly object.
Exercise
We would like to represent the whole game as one object called
Game. Currently, we have coded only two game components, so
our monopoly game will be a very small one. The Game object
has a Dice object, and it also has an
Account object. Obviously, the Game object is
a monopoly object, so it should be derived from Base.
- Make sure you have working code for the three classes
Base, Dice and Account from the previous exercises.
- Use the following main.C:
#include "Game.h"
main()
{
Game game;
game.read();
game.write();
}
- Write the header file Game.h and it's implementation
file Game.C. Remember that Game inherits from
Base, and should define the readContents and
writeContents member functions. Note that the implementation
of these functions should be as simple as possible (all member
functions should consist of 2 (two) statements at most) and should use the
interface defined in the previous exercise.
- Compile and test your program with the following input
file. The output file should be similar to the input file.
Game
Dice 3 5 end
Account 300 end
end
- The output should be reusable as input. Call the executable
monopoly, and use the following command:
% monopoly <inputfile | monopoly >outputfile
This pipes the output of the first monopoly process into the second
monopoly process. This should produce an output file similar to the
input file.
Finished Early?
You should start looking at the manual pages for aegis. You
might also want to look at User's Guide.
Add the following line to your .cshrc file:
source /public/u-aizu/lib/aegis/cshrc
Try out commands like ael p...
Look up what the .aegisrc file should contain for
your project.
Christian Goetze