Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. ///////////////////Player.h/////////////////
  2. #pragma once
  3. #include <string>
  4.  
  5. class Player
  6. {
  7. private:
  8.  
  9. int m_dice;
  10.  
  11. public:
  12.  
  13. Player()
  14. {
  15.  
  16. }
  17.  
  18. void RollDice();
  19.  
  20. const int& GetDice() const
  21. {
  22. return m_dice;
  23. }
  24. };
  25.  
  26. //////////////////gameloop.h/////////////
  27. #pragma once
  28. #include "Player.h"
  29. #include "PlayerOptions.h"
  30. #include <string>
  31.  
  32.  
  33. class Game
  34. {
  35. private:
  36. int m_noOfPlayers;
  37. Player *m_player;
  38.  
  39.  
  40. void WelcomePlayer();
  41.  
  42.  
  43.  
  44. public:
  45.  
  46. void RunGame();
  47.  
  48. void setNoOfPlayers(const int& noOfPlayers)
  49. {
  50. m_noOfPlayers = noOfPlayers;
  51. }
  52.  
  53. const int& GetNoOfPlayers() const
  54. {
  55. return m_noOfPlayers;
  56. }
  57.  
  58. };
  59.  
  60. ///////////////////gameloop.cpp////////////
  61.  
  62. // NathanWood_Final.cpp : Defines the entry point for the console application.
  63. //
  64. #include "Player.h"
  65. #include "stdafx.h"
  66. #include "GameLoop.h"
  67. #include <string>
  68. #include <fstream>
  69. #include <iostream>
  70. #include <ctime>
  71.  
  72.  
  73. //using namespace std;
  74.  
  75.  
  76.  
  77. void Game::WelcomePlayer()
  78. {
  79. std::string line;
  80. std::ifstream myfile("Rules.txt");
  81. if (myfile.is_open())
  82. {
  83. while (getline(myfile, line))
  84. {
  85. std::cout << line << '\n';
  86. }
  87. myfile.close();
  88. }
  89. else std::cout << "Unable to open file";
  90.  
  91. std::cout << "\nWelcome to liars dice. How many players are playing?";
  92. int noOfPlayers;
  93. std::cin >> noOfPlayers;
  94. const int n = noOfPlayers;
  95.  
  96. if (noOfPlayers > 0) {
  97. m_player.setNoOfPlayers(noOfPlayers);
  98. Player *ArrPlayers = new Player[noOfPlayers];
  99. }
  100. else
  101. std::cout << "That is not a valid choice";
  102.  
  103.  
  104. }
  105.  
  106. void Player::RollDice()
  107. {
  108. srand((unsigned int)time(NULL)); //seed the random # generator
  109.  
  110. const int noOfPlayers = m_player.GetNoOfPlayers();
  111. for (int i = 0; i < noOfPlayers; ++i)
  112. {
  113. //TODO:: roll the dice
  114. //(rand() % 6) + 1;
  115. }
  116.  
  117.  
  118.  
  119. }
  120.  
  121.  
  122.  
  123.  
  124.  
  125. void Game::RunGame()
  126. {
  127. WelcomePlayer();
  128. RollDice();
  129.  
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement