fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void start();
  5. int humanTurn(int humanTotalScore);
  6. int computerTurn(int computerTotalScore);
  7. int numberTest = 5;
  8. int humanTotalScore = 0;
  9.  
  10.  
  11.  
  12. int main()
  13. {
  14. start();
  15. humanTurn(numberTest);
  16.  
  17.  
  18. return 0;
  19.  
  20.  
  21.  
  22. }
  23.  
  24.  
  25. void start()
  26. {
  27. cout << "Welcome to the game of Pig!\n"
  28. << "This game is a simple two player dice game.\n"
  29. << "The first person to 100 points wins\n"
  30. << "On a players turn, they begin by rolling a dice\n"
  31. << "-If a player rolls a 2-6 they may:\n"
  32. << "Roll again\n"
  33. << "Hold\n"
  34. << "If a player holds, their points are added to their total\n"
  35. << "And the next player's turn begins\n"
  36. << "-If a player rolls a 1, they lose their turn\n"
  37. << "And the next player's turn begins\n\n"
  38. << "Player 1 rolls first.\n";
  39.  
  40. }
  41.  
  42. int humanTurn(int humanTotalScore)
  43. {
  44. cout << "Player 1 rolls "<< numberTest;
  45. cout << "Your total score is: " << humanTotalScore;
  46. cout <<"Do you want to roll again?('r' to roll again, 'h' to hold.)";
  47. cin >> rollDecision;
  48.  
  49. if rollDecision == "r"
  50. {
  51. cout << "You roll again.\n"
  52. }
  53.  
  54. else if rollDecision == "h"
  55. {
  56. cout << "You decide to hold.\n"
  57. }
  58. return numberTest;
  59. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int humanTurn(int)’:
prog.cpp:47:9: error: ‘rollDecision’ was not declared in this scope
  cin >> rollDecision;
         ^~~~~~~~~~~~
prog.cpp:49:5: error: expected ‘(’ before ‘rollDecision’
  if rollDecision == "r"
     ^~~~~~~~~~~~
prog.cpp:54:2: error: ‘else’ without a previous ‘if’
  else if rollDecision == "h"
  ^~~~
prog.cpp:54:10: error: expected ‘(’ before ‘rollDecision’
  else if rollDecision == "h"
          ^~~~~~~~~~~~
stdout
Standard output is empty