Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. //Samuel Caldwell
  2. //2-4-2016
  3. //Assignment 3 Horserace
  4.  
  5. #include <string>
  6. using namespace std;
  7.  
  8. class Race{//creating the class known as race to create the layout
  9.  
  10. 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
  11. private: Horse h[5];
  12. }
  13.  
  14. public: Race(len){//length of the race that needs to be the length you desire for your race, for this project it was 25
  15. length = 25;
  16. }
  17.  
  18. public: printLane(horseNum){//the start of printing a singular lane for each horse that later on just is repeated rather than seperate lanes itself
  19. for (int i = 0; i < 25; i++){
  20. if (i == 0-24) = setPosition;
  21. cout << horseNum;
  22. else cout << ".";
  23. }
  24.  
  25. }
  26.  
  27. public: start(){//the start which can be used to "start" the program with the press of enter and also the stopping of enter
  28. while keepgoing{//starting a while loop that only stops when enter is pressed
  29. for 0-4 horses call advance;
  30. printLane(horseNum);
  31. if(positon == 24){
  32. KeepGoing = false;
  33. cout << "Press Enter";
  34. cin.ignore();
  35. for 0-24 = x{
  36. if x = setPosition();
  37. cout << horseNum;
  38. else cout << ".";
  39.  
  40. }
  41.  
  42. }
  43. }
  44. }
  45.  
  46. class Horse{//the class horse that creates
  47. private position;
  48.  
  49. public: Horse(){//the variable Horse which is also the numbers themselves 0-4
  50. position = 0;
  51. }
  52.  
  53. public: advance()://advance which means the chance of each horse moving one dot forward until the end
  54. void generate random number(0,1), 50% chance of...;
  55. position + 1, if 0 or 1;
  56.  
  57. public: getPosition()://the reading of the position each horse is at considering
  58. int return position;
  59. }
  60.  
  61. main(){
  62. Race = r;
  63. r.start();
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement