// aquadisplay.cpp // // Chris Nevison // March 15, 2000 // // This file defines a class AquaDisplay for the Aquarium simulation // defined in the files aquafish.h/cpp and aquamain.cpp. // This simulation shows the fish position in the aquarium after // each move. // The AquaDisplay class requires the the AquaFish class have // two public member functions not originally defined: // // Position, which returns an int for the position of the fish // in the tank (form 0 to tankSize - 1 inclusive) // // Direction, which returns a character 'l' or 'r' indicating // the current direction of the fish. // #include #include "aquadisplay.h" AquaDisplay::AquaDisplay(int tankSize) : myTankSize(tankSize) { } void AquaDisplay::ShowFish(AquaFish f) { int k; cout << "||"; for(k = 0; k < myTankSize; k++) { if(k == f.Position()) { if(f.Direction() == 'l') cout << "<-"; else if (f.Direction() == 'r') cout << "->"; else cout << "Error in fish direction in ShowFish." << endl; } else cout << "__"; } cout << "||" << endl; }