| 12345678910111213141516171819202122232425262728293031323334 |
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <time.h>
- #include "Horse.h"
- Horse::Horse(){
- position = 0;
- isRacing = true;
- }
- int Horse::getPosition(){
- return position;
- }
- // flips a coin, advances ~50% of times
- void Horse::advance(){
- if (rand() % 2){ // either 0 or 1
- position++;
- }
- }
- bool Horse::getRacing(){
- return isRacing;
- }
- void Horse::race(){
- isRacing = true;
- }
- void Horse::dontRace(){
- isRacing = false;
- }
|