Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. /* Keenen Topple
  2. Minesweeper project 1
  3. */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <ctype.h>
  7.  
  8. void initilization()
  9. {
  10. printf("____________________________Minesweeper____________________________\n");
  11. printf("***Setting up the Game***\n");
  12. }
  13.  
  14. void tearDown()
  15. {
  16. printf("____________________________Destroying_The_Game____________________________\n");
  17. }
  18.  
  19. int worldUpdate(int row, int column)
  20. {
  21. while(row > -1 && row < 11);
  22. {
  23. printf("Please enter a Horizontal coordinate 0-10 and press enter.\n");
  24. scanf("%d", &row);
  25. }
  26.  
  27. while(column > -1 && column < 11);
  28. {
  29. printf("Please enter a Vertical coordinate 0-10 and press enter.\n");
  30. scanf("%d", &column);
  31. }
  32.  
  33. if((row=0)&&(column=0))
  34. {
  35. printf("BOOM, GAME OVER.\n");
  36. return 1;
  37. }
  38. else
  39. {
  40. printf("Okay, No bombs were hit.\n");
  41. }
  42. return 0;
  43. }
  44.  
  45. void worldDisplay()
  46. {
  47. printf("Display the state of the world – Print the result calculated in the state of the world. Later, this should print the board.\n");
  48. }
  49.  
  50. int acceptInput()
  51. {
  52. int row;
  53. int column;
  54. char menu;
  55. printf("____________________________MENU____________________________\n");
  56.  
  57. printf("(F) flag a spot as a mine, (R) remove a flag, (A) assert that spot is mine free, (Q) quit the game\n");
  58. scanf("%c", &menu);
  59. getchar();
  60. menu = toupper(menu);
  61. printf("input: %c", menu);
  62.  
  63. switch(menu)
  64. {
  65. case 'F':
  66. {
  67. printf("Input successfully entered as F!");
  68. break;
  69. }
  70. case 'R':
  71. {
  72. printf("Input successfully entered as R!");
  73. break;
  74. }
  75. case 'A':
  76. {
  77. printf("Input successfully entered as A!");
  78.  
  79. break;
  80. }
  81. case 'Q':
  82. {
  83. printf("Input successfully entered as Q!");
  84.  
  85. tearDown();
  86. break;
  87. }
  88. default:
  89. {
  90. printf("Bad input, Try again.\n");
  91. acceptInput();
  92. }
  93. }
  94.  
  95. printf("input successful4");
  96. }
  97.  
  98. int main()
  99. {
  100. int lost = 0;
  101. int row;
  102. int column;
  103. initilization();
  104. do
  105. {
  106. acceptInput();
  107. worldUpdate(row, column);
  108. worldDisplay();
  109. }while(lost != 1);
  110. tearDown();
  111. return 0;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement