#include "common.H" #include "Sayer.H" Sayer::Sayer(){ utterance = ""; } Sayer::Sayer(string blah){ utterance = blah; } void Sayer::say(){ cout << utterance; } NoisySayer::NoisySayer() : Sayer("Pikachu"), freq(5){ } NoisySayer::NoisySayer(string blah, int times) : Sayer(blah), freq(times){ } void NoisySayer::say(){ for(int i = 0; i < freq; i++){ cout << "\t" << utterance << "!\n"; } } ObedientSayer::ObedientSayer(string yap, int times) : NoisySayer(yap, times), currFreq(times){ } void ObedientSayer::say() { NoisySayer::say(); } void pet(ObedientSayer &os){ if(os.currFreq > 1) os.currFreq--; for(int i = 0; i < os.currFreq; i++){ os.Sayer::say(); cout << " "; } } void squeeze(ObedientSayer &os){ os.currFreq++; for(int i = 0; i < os.currFreq; i++){ os.Sayer::say(); cout << "!!! "; } } Quacker::Quacker() : NoisySayer("quack-quack", 2){ } void Quacker::quack(){ NoisySayer::say(); }