Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Samuel Caldwell
- //2-4-2016
- //Assignment 3 Horserace
- #include <string>
- using namespace std;
- class Race{//creating the class known as race to create the layout
- public: Race(){//the public variable race which is just the start so that later on you keep adding onto it such as the lane and race itself
- private: Horse h[5];
- }
- public: Race(len){//length of the race that needs to be the length you desire for your race, for this project it was 25
- length = 25;
- }
- public: printLane(horseNum){//the start of printing a singular lane for each horse that later on just is repeated rather than seperate lanes itself
- for (int i = 0; i < 25; i++){
- if (i == 0-24) = setPosition;
- cout << horseNum;
- else cout << ".";
- }
- }
- public: start(){//the start which can be used to "start" the program with the press of enter and also the stopping of enter
- while keepgoing{//starting a while loop that only stops when enter is pressed
- for 0-4 horses call advance;
- printLane(horseNum);
- if(positon == 24){
- KeepGoing = false;
- cout << "Press Enter";
- cin.ignore();
- for 0-24 = x{
- if x = setPosition();
- cout << horseNum;
- else cout << ".";
- }
- }
- }
- }
- class Horse{//the class horse that creates
- private position;
- public: Horse(){//the variable Horse which is also the numbers themselves 0-4
- position = 0;
- }
- public: advance()://advance which means the chance of each horse moving one dot forward until the end
- void generate random number(0,1), 50% chance of...;
- position + 1, if 0 or 1;
- public: getPosition()://the reading of the position each horse is at considering
- int return position;
- }
- main(){
- Race = r;
- r.start();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement