fork download
  1. #include <iostream>
  2. #include <time.h>
  3. #include <stdlib.h>
  4. #include <cmath>
  5. #include<conio.h>
  6.  
  7. using namespace std;
  8.  
  9. int main ()
  10. {
  11.  
  12. char name[100];
  13. char dec;
  14. char cont;
  15. int code;
  16. int codeCounter;
  17. int num;
  18. cout <<" Enter agent name: "<<endl;
  19.  
  20. cin.getline(name, 100);
  21. cout << "Welcome agent "<< name << " you have been chosen to fulfill a very important mission."<<endl;
  22. cout<<"Do you accept the mission?" <<endl;
  23. cout <<"Good. Let's begin. Press any character to continue " <<endl;
  24. _getch();
  25. cout << "Okay first you should know that the address is 1337 E. Yanky Drive"
  26. << " Now the first decision of the mission is whether to enter from the front or back"
  27. << " Type F for front or B for back";
  28.  
  29. cin>>dec;
  30.  
  31. //Random number decides whether or not alarm is triggered.
  32. // If user decides to enter from the front then a random number will be called.
  33. // If the number is even the alarm is triggered and user has to guess it given the a hint.
  34. // The code is the address backwards. They are given the hint that the code involves the address.
  35.  
  36.  
  37.  
  38. switch (dec)
  39. {
  40. case 'f':
  41. srand(time(NULL));
  42. num = rand() % 1000 + 1;
  43. cout << num <<endl;
  44. if(num%2==0)
  45. {
  46. cout<<"You triggered the alarm" << endl;
  47. while (code != 7331)
  48. {
  49. cout<<"Enter the code to disable it: "
  50. <<" \n *HINT* Code involves the address. " << endl;
  51. cin>> code;
  52. codeCounter++;
  53. //After 3 tries user is given another hint.
  54. if (codeCounter ==3)
  55. {
  56. cout << "Hint: Reverse address" <<endl;
  57. }
  58. }
  59. }
  60. else
  61. {
  62. cout<< "You made it in safely. "<< endl;
  63. }
  64. break;
  65. case 'b':
  66. cout << " Good!! You have successfully breached in the back" << endl;
  67. case 'F':
  68. num = rand() % 1000 + 1;
  69.  
  70. if(num%2==0)
  71. {
  72. cout<<"You triggered the alarm" << endl;
  73. while (code != 7331)
  74. {
  75. cout<<"Enter the code to disable it: "
  76. <<" \n *HINT* Code involves the address. " << endl;
  77. cin>> code;
  78. codeCounter++;
  79. //After 3 tries user is given another hint.
  80. if (codeCounter ==3)
  81. {
  82. cout << "Hint: Reverse address" <<endl;
  83. }
  84. }
  85. }
  86. else
  87. {
  88. cout<< "You made it in safely. "<< endl;
  89. }
  90.  
  91. break;
  92. case 'B':
  93. cout<< "Good. You have successfully breached in the back. " <<endl;
  94. break;
  95.  
  96. default:
  97. cout << "F or B..." << endl;
  98. break;
  99. }
  100.  
  101. do{
  102. cout << "Now that you're in the house " <<endl;
  103. cout << "Where do you want to look first (Enter corresponding letter) "
  104. << " \n Kitchen (K) "
  105. << " \n Living room (L) "
  106. << " \n Basement (B) "
  107. << " \n Upstairs Bedroom (U) "
  108. << " \n Master Bedroom (M) "
  109. << " \n Bathroom (N) "
  110. << " \n Attic (A) "
  111. << endl;
  112.  
  113. // Kitchen we want a note leading the player to the basement to find more clues (randomize the note).
  114. // Living room we want the black box with the information of the terrorists.
  115. // Items: Crow bar, key, blue prints of the inside of the house, axe, screw driver, pen and paper from the note.
  116. // We want the items to be randomized in these locations and when the player types in " Living Room" he is then printed.....
  117. // .....
  118.  
  119.  
  120. char y_nTen;
  121. char y_nNine;
  122. char y_nEight;
  123. char y_nSeven;
  124. char y_nSix;
  125. char y_nFive;
  126. char y_nFour;
  127. char y_nThree;
  128. char y_nTwo;
  129. char y_nOne;
  130. char look;
  131. int screwdrive = 0;
  132. int crowbar = 0;
  133. int key = 0;
  134. int items = 0;
  135. int blueprint = 0;
  136. int letter = 0;
  137. int axe = 0;
  138. int p_p = 0;
  139. cin>>look;
  140.  
  141. if(look == 'K' || look == 'K'){
  142. cout << "You notice a screwdriver on the counter. Do you pick it up? "
  143. <<"\t Y/N" <<endl;
  144. cin>>y_nOne;
  145. if( y_nOne == 'Y' || y_nOne == 'y'){
  146. if( items < 3){
  147. items++;
  148. screwdrive++;
  149. cout<< "You now have a screwdriver." <<endl;
  150. }
  151. else if(items>=3){
  152. cout<<"You already have three items. You can only have three."<<endl;
  153.  
  154. }
  155.  
  156. }
  157.  
  158.  
  159. }
  160. if(look == 'L' || look == 'l'){
  161. cout << "You walk through the living room and notice there is a loose floor board. Do you examine it?"
  162. << "\t Y/N" <<endl;
  163. cin>>y_nTwo;
  164. if( y_nTwo == 'Y')
  165. {
  166. if (screwdrive == 1 ){
  167. cout<< "You use the screwdriver to pry it open. There is a box underneath. Do you want to open it?"
  168. <<"\t Y/N" <<endl;
  169. cin>>y_nThree;
  170. if(y_nThree == 'Y' || y_nThree == 'y'){
  171. if(key == 1){
  172. cout << "Congratulation! You found the terrorists plans and saved the world!" <<endl;
  173. }
  174. else{
  175. cout<<"The box is locked...you probably should've taken that key when you had the chance..."<<endl;
  176. }
  177. }
  178. }
  179. else if (crowbar == 1){
  180. cout<< "You use the crowbar to pry it open. There is a box underneath. Do you want to open it?"
  181. <<"\t Y/N" <<endl;
  182. cin>>y_nThree;
  183. if(y_nThree == 'Y' || y_nThree == 'y'){
  184. if(key == 1){
  185. cout << "Congratulation! You found the terrorists plans and saved the world!" <<endl;
  186. }
  187. else{
  188. cout<<"The box is locked...you probably should've taken that key when you had the chance..."<<endl;
  189. }
  190. }
  191. }
  192. else{
  193. cout<<"It's stuck...you need some tools to open it. Perhaps a screwdriver or crowbar?"<<endl;
  194.  
  195. }
  196. }
  197. }
  198. if(look == 'b' || look == 'B'){
  199. cout<<"As you examine the kitchen you notice a loose brick in the wall. After checking it out there is a key behind the brick. "
  200. <<"Do you want to pick it up?"
  201. <<"\n Y/N?" <<endl;
  202. cin>>y_nFour;
  203. if(y_nFour == 'y' || y_nFour == 'Y'){
  204. if(items < 3){
  205. items++;
  206. key++;
  207. cout<<"You have a key now." <<endl;
  208. }
  209. else if(items >= 3){
  210. cout<< "You already have 3 items. You can only carry three." <<endl;
  211.  
  212. }
  213. if(y_nFour == 'N' || y_nFour == 'n'){
  214. cout<< "Suit yourself. " <<endl;
  215. }
  216. }
  217. }
  218. cout<<"While looking through the basement you find a crowbar. Do you want to keep the crow bar?"
  219. <<"\n Y/N" <<endl;
  220. cin>>y_nFive;
  221. if(y_nFive == 'Y' || y_nFive == 'y' ){
  222. if(items < 3){
  223. items ++;
  224. crowbar++;
  225. cout<< "You now have a crowbar." <<endl;
  226.  
  227.  
  228. }
  229. else if(items>= 3){
  230. cout<< "You already have three items. You can only carry three." <<endl;
  231. }
  232. }
  233. if(y_nFive == 'n' || y_nFive == 'N'){
  234. cout<< "Suit yourself."<<endl;
  235. }
  236. }
  237. if(look == 'U' || look == 'u'){
  238. cout<<"While looking through the upstairs bedroom you find some an axe. Do you want to keep the axe?"
  239. <<"\n Y/N" <<endl;
  240. cin>>y_nFive;
  241. if(y_nFive == 'Y' || y_nFive == 'y' ){
  242. if(items < 3){
  243. items ++;
  244. axe++;
  245. cout<< "You now have an axe." <<endl;
  246.  
  247.  
  248. }
  249. else if(items>= 3){
  250. cout<< "You already have three items. You can only carry three." <<endl;
  251.  
  252. }
  253. }
  254. if(y_nFive == 'n' || y_nFive == 'N'){
  255. cout<< "Suit yourself."<<endl;
  256. }
  257. }
  258. if(look == 'M' || look == 'm'){
  259. cout<<"While looking through the master bedroom you find a letter addressed to no one in particular. Do you want to keep the letter?"
  260. <<"\n Y/N" <<endl;
  261. cin>>y_nFive;
  262. if(y_nFive == 'Y' || y_nFive == 'y' ){
  263. if(items < 3){
  264. items ++;
  265. letter++;
  266. cout<< "You now have a letter." <<endl;
  267.  
  268.  
  269. }
  270. else if(items>= 3){
  271. cout<< "You already have three items. You can only carry three." <<endl;
  272. }
  273. }
  274. if(y_nFive == 'n' || y_nFive == 'N'){
  275. cout<< "Suit yourself."<<endl;
  276. }
  277. }
  278. if(look == 'N' || look == 'n' ){
  279. cout<<"While looking through the bathroom you find a pen and paper . Do you want to take the pen and paper with you? (Only counts as one item)"
  280. <<"\n Y/N" <<endl;
  281. cin>>y_nFive;
  282. if(y_nFive == 'Y' || y_nFive == 'y' ){
  283. if(items < 3){
  284. items ++;
  285. p_p++;
  286. cout<< "You now have blue prints." <<endl;
  287.  
  288.  
  289. }
  290. else if(items>= 3){
  291. cout<< "You already have three items. You can only carry three." <<endl;
  292. }
  293. }
  294. if(y_nFive == 'n' || y_nFive == 'N'){
  295. cout<< "Suit yourself."<<endl;
  296. }
  297. }
  298. if(look == 'a' || look == 'A'){
  299. cout<<"While looking through the attic you find some blueprints. Do you want to keep these blue prints?"
  300. <<"\n Y/N" <<endl;
  301. cin>>y_nFive;
  302. if(y_nFive == 'Y' || y_nFive == 'y' ){
  303. if(items < 3){
  304. items ++;
  305. blueprint++;
  306. cout<< "You now have blue prints." <<endl;
  307.  
  308.  
  309. }
  310. else if(items>= 3){
  311. cout<< "You already have three items. You can only carry three." <<endl;
  312. }
  313. }
  314. if(y_nFive == 'n' || y_nFive == 'N'){
  315. cout<< "Suit yourself."<<endl;
  316. }
  317.  
  318. }
  319.  
  320. }while(true);
  321. return 0;
  322.  
  323. }
  324.  
  325.  
  326.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:18: fatal error: conio.h: No such file or directory
 #include<conio.h>
                  ^
compilation terminated.
stdout
Standard output is empty