Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.36 KB | None | 0 0
  1. // A program to keep track of points and time and to give a random letter for the game scattergories
  2.  
  3. #include<iostream>
  4. #include<Windows.h>
  5. using std::cout;
  6. using std::cin;
  7.  
  8. void ltr() //gives a random letter
  9. {
  10. char letter;
  11. letter = rand() % 27 + 64; //assigns a random letter in ascii code to a char (resulting in a random letter)
  12. cout << "The letter is " << letter << "n";
  13. }
  14.  
  15. void clock() //timer
  16. {
  17. cout << "You got 1.5 minutes to finishn";
  18. for (int i = 90; i > 0; i--)
  19. {
  20. if (i % 5 == 0)
  21. cout << i << "n";
  22. Sleep(1000);
  23. }
  24. cout << "DING DONG!!! DING DONG!!! Time's up!!!n";
  25. }
  26.  
  27. int points() //points per round
  28. {
  29. int a, b, c, sum;
  30. cout << "How many sections only you got?n"; //worth 15 points
  31. cin >> a;
  32. cout << "How many words only you got?n"; //worth 10 points
  33. cin >> b;
  34. cout << "How many words you and another person got?n"; //worth 5 points
  35. cin >> c;
  36. sum = a * 15 + b * 10 + c * 5;
  37. return sum; //Note: It doesn't matter how many sections there are.
  38. }
  39.  
  40. int act()
  41. {
  42. int Points;
  43. ltr();
  44. clock();
  45. Points=points();
  46. cout << "You have earned " << Points << " this roundnn";
  47. return Points;
  48. }
  49.  
  50. int main()
  51. {
  52. int Points;
  53. cout << "Starting in five secondsn";
  54. Sleep(5000);
  55. Points = act();
  56. for (;;) //inf loop
  57. {
  58. int ph;
  59. cout << "Press 1 to continue or 2 to stopn";
  60. cin >> ph;
  61. if (ph == 1)
  62. {
  63. Points += act();
  64. }
  65. else
  66. {
  67. break;
  68. }
  69. }
  70. cout << "You have earned a total of " << Points << " great job!nn";
  71. system("pause");
  72. }
  73.  
  74. #include <Windows.h>
  75.  
  76. Sleep(1000);
  77.  
  78. std::this_thread::sleep_for(1s); // needs to #include <thread>
  79.  
  80. letter = rand() % 27 + 64;
  81.  
  82. cin >> ph;
  83.  
  84. bool stop = false;
  85. do
  86. {
  87. int ph;
  88. cout << "Press 1 to continue or 2 to stopn";
  89. if(cin >> ph) {
  90. if (ph == 1)
  91. {
  92. Points += act();
  93. }
  94. else if(ph == 2)
  95. {
  96. stop = true;
  97. }
  98. }
  99. else {
  100. cin.clear();
  101. std::string dummy;
  102. std::getline(cin,dummy); // Consume the invalid input
  103. }
  104. } while(!stop);
  105.  
  106. /* To do list:
  107. *Convert to arduino
  108. *Make timer work in background of of table
  109. *Check if words in the table (for differant players) are the same and give points accordingly
  110. *Check if words are actual words (connect an online dictonary?)
  111. *Make interface? (if possible and I have time to learn how)
  112. *Think of what to do with Hardwear
  113. *Comment rest of the code
  114. */
  115.  
  116.  
  117. // A program to keep track of points and time and to give a random letter for the game scattergories
  118. #include "stdafx.h"
  119. #include<iostream>
  120. #include<time.h>
  121. #include<string>
  122. using std::cout;
  123. using std::cin;
  124. using std::string;
  125. using std::getline;
  126.  
  127. void ltr() //gives a random letter
  128. {
  129. srand(time(NULL)); //gives a differant pattern every time
  130. char letter;
  131. letter = rand() % 27 + 64; //assigns a random letter in ascii code to a char (resulting in a random letter)
  132. cout << "The letter is " << letter << "n";
  133. }
  134.  
  135. void timer()
  136. {
  137. cout << "You got 1.5 minutes to finishn";
  138. for (int i = 90; i > 0; i--)
  139. {
  140. if (i % 5 == 0)
  141. cout << i << "n";
  142. _sleep(1000);
  143. }
  144. cout << "DING DONG!!! DING DONG!!! Time's up!!!n";
  145. }
  146.  
  147. void table()
  148. {
  149. int plr, ctr;
  150. string lst[5][20]; //first dimantion: how many players. second dimantion: how many catagories, third dimantion(if added) will be the round
  151. cin>>plr>>ctr; //parameters for later
  152. cin.ignore(); //To avoid the "getline" reading the last input
  153. for(int x=0;x<plr;x++) //the player changes only after the previus player finishes
  154. {
  155. timer();
  156. for(int i=0;i<ctr;i++) //changing catagory
  157. {
  158. getline(cin,lst[x][i]);
  159. }
  160. system("cls");
  161. cout<<"Next playern";
  162. }
  163. for(int x=0;x<plr;x++) //this part (the whole "for" loop) is for confirming
  164. {
  165. cout<<"Player number "<<x+1<<": ";
  166. for(int i=0;i<ctr;i++)
  167. {
  168. cout<<lst[x][i]<<" ";
  169. }
  170. cout<<"n";
  171. }
  172. _sleep(5000);
  173. }
  174.  
  175. int points() //points per round
  176. {
  177. int a, b, c, sum;
  178. cout << "How many sections only you got?n"; //worth 15 points
  179. cin >> a;
  180. cout << "How many words only you got?n"; //worth 10 points
  181. cin >> b;
  182. cout << "How many words you and another person got?n"; //worth 5 points
  183. cin >> c;
  184. sum = a * 15 + b * 10 + c * 5;
  185. return sum; //Note: It doesn't matter how many sections there are.
  186. }
  187.  
  188. int act()
  189. {
  190. int Points;
  191. ltr();
  192. table();
  193. Points = points();
  194. cout << "You have earned " << Points << " this roundnn";
  195. return Points;
  196. }
  197.  
  198. int main()
  199. {
  200. int Points;
  201. cout << "Starting in five secondsn";
  202. _sleep(5000);
  203. Points = act();
  204. for (;;) //inf loop
  205. {
  206. int ph;
  207. cout << "Press 1 to continue or anything else to stopn";
  208. cin >> ph;
  209. if (ph == 1)
  210. {
  211. Points += act();
  212. }
  213. else
  214. {
  215. break;
  216. }
  217. }
  218. cout << "You have earned a total of " << Points << " great job!";
  219. _sleep(5000); //time to read the last text
  220. return 0;
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement