chickenSim - #include "Chicken.h" #include "Hen.h" / 3....

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include "Chicken.h" #include "Hen.h" // 3. #include "Breeds.h" #include <iostream> #include <vector> using namespace std ; void multiHenSimulation() ; void singleHenSimulator(Hen*) ; void subClassAssignment() ; int main() { cout << endl << endl << "Welcome to ChickenSim!" << endl << endl << endl ; // A simulator for a single hen. singleHenSimulator(new Hen() ) ; // A simulator for a subclass of Hen. We can pass a pointer to a // subclass to any place we could pass a pointer to one of its // superclasses. singleHenSimulator(new RhodeIslandRed() ) ; multiHenSimulation() ; } void singleHenSimulator( Hen* h) { int totalFeedConsumed = 0 ; int totalEggsLaid = 0 ; cout << "Running single hen simulator for a " << h->breed() << "." << endl << endl ; const int NumDays = 10 ; totalFeedConsumed = 0 ; totalEggsLaid = 0 ; for (int day=0; day<NumDays; ++ day) { h->goToSleep() ; totalFeedConsumed += h->feedConsumed() ; int aNewEgg = h->laidAnEgg() ; totalEggsLaid += aNewEgg ;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/28/2010 for the course CSCI 1113 taught by Professor Staff during the Spring '08 term at Minnesota.

Page1 / 3

chickenSim - #include "Chicken.h" #include "Hen.h" / 3....

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online