#ifndef _OBSERVER_H #define _OBSERVER_H // a class for observing a one-dimensional random walk // this version records the events of the walk for plotting with samba // // WalkObserver(ostream & OutputStream, -- Constructor is given a stream // int maxWalkers to send data to. It needs // to know how many walkers it // will be watching so that it // can draw them at their initial // position // // // void Update(RandomWalk & walker) -- called by a walking object // to observe (record) a walk #include "CPstring.h" class RandomWalk; // the walker class that will be observed class WalkObserver { public: WalkObserver(ostream & OutputStream, int maxWalkers=1); void Update(RandomWalk & walker); // update information from walker private: void InitializeStream(int maxWalkers); //InitializeStream string GetColorFromID (int colorID); //Get Color int GetYFromID(int id); void WalkObserver::DrawRectangle (int id, double x, double y); void MoveRectangle (int ID, double x, double y); ostream & myOutputStream; // output stream for data double myWidth; double myHeight; }; #endif