walko2.cc From Astrachan p 331 ------------------------------- #include "walko.h" #include "dice.h" // part of walko.cc, just the member functions that are different // than the functions for the class RandomWalk RandomWalkO::RandomWalkO(WalkObserver & obs, int maxSteps) : myObserver(obs) // postcondition: all private data fields initialized { myPosition = mySteps = 0; myMaxSteps = maxSteps; } void RandomWalkO::TakeStep() // postcondition: one step of random walk taken { Dice coin(2); switch (coin.Roll()) { case 1: myPosition--; break; case 2: myPosition++; break; } mySteps++; myObserver.Update(mySteps,myPosition); }