Guest User

World War II trivia PS

a guest
Sep 23rd, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.73 KB | None | 0 0
  1.  
  2. # **********************************************************************
  3. #
  4. # Script Name: WWII.ps1 (World War II Trivia Quiz)
  5. # Version: 2.0
  6. # Author: Paul Ferguson
  7. # Date: September 23, 2015
  8. #
  9. # Description: This PowerShell script tests the player's knowledge
  10. # of World War II trivia through the administration of
  11. # a computer quiz made up of 5 questions.
  12. #
  13. # **********************************************************************
  14.  
  15. # Clear the Windows command console screen
  16. Clear-Host
  17.  
  18. # Define the array used in this script to store questions
  19. $question1 = " What was the treaty that ended WWI that laid some of the unrest that would later explode into WWII?"
  20. $question2 = " Hitler became the essential dictator of Germany in which decade?"
  21. $question3 = " What war during the 1930s greatly influenced the development of military tactics that were used in WWII?"
  22. $question4 = " What was the last major attempt at a peaceful resolution with Germany prior to the outbreak of WWII?"
  23. $question5 = " What event began World War II?"
  24.  
  25.  
  26. # Define the array used in this script to store player answers
  27. $answers = "","","","","","","","","",""
  28.  
  29. # Define the array used in this script to store valid answers
  30. $valid = "a","b","c","d"
  31.  
  32. # Define the array used in this script to store correct answers
  33. $correctAnswers = "b","d","c","a","c",
  34.  
  35. # Define a variable to keep track of the number of correctly answered quiz questions
  36. $noCorrect = 0
  37.  
  38. # Display the game's opening screen
  39. Write-Host "`n`n`n`n`t`t W E L C O M E T O T H E "
  40. Write-Host "`n`n`n`t`t`t W O R L D W A R T R I V I A"
  41. Write-Host "`n`n`n`t`t`t`t By Paul Ferguson"
  42. Write-Host "`n`n`n`n`n`n`n`n`n`n Press Enter to continue."
  43.  
  44. # Pause script execution and wait for the player to press the Enter key
  45. Read-Host
  46.  
  47. # Clear the Windows Command Console Screen
  48. Clear-Host
  49.  
  50. # Provide the player with instructions
  51. Write-Host "`n`n The World War Trivia Quiz tests your knowledge of Seinfeld`n"
  52. Write-Host " trivia. The quiz consists of five equally weighted multiple`n"
  53. Write-Host " choice questions. At the end of the quiz your answers will`n"
  54. Write-Host " be checked and you will be assigned a skill level, using`n"
  55. Write-Host " the following scale.`n`n"
  56. Write-Host " `t Score: 5 correct = Invasion of Poland"
  57. Write-Host " `t`t 6-7 correct = The Munich Conference"
  58. Write-Host " `t`t 4-5 correct = The Spanish Civil War"
  59. Write-Host " `t`t 2-3 correct = 1930s"
  60. Write-Host " `t`t 0-1 correct = Treaty of Versailles"
  61. Write-Host "`n`n`n`n Press Enter to continue."
  62.  
  63. # Pause script execution and wait for the player to press the Enter key
  64. Read-Host
  65.  
  66. # Ask the player the first question
  67. while ($valid -notcontains $answers[0]) {
  68.  
  69. Clear-Host # Clear the Windows command console screen
  70.  
  71. Write-Host
  72. Write-Host $question1
  73. Write-Host
  74. Write-Host " A. Geneva Conference"
  75. Write-Host " B. Treaty of Versailles"
  76. Write-Host " C. Paris Peace Accords"
  77. Write-Host " D. Treaty of Brest-Litovsk"
  78. Write-Host
  79. $answers[0] = Read-Host "Type the letter representing the correct" `
  80. " answer and press the Enter key."
  81. }
  82.  
  83. # Ask the player the second question
  84. while ($valid -notcontains $answers[1]) {
  85.  
  86. Clear-Host # Clear the Windows command console screen
  87.  
  88. Write-Host
  89. Write-Host $question2
  90. Write-Host
  91. Write-Host " A. 1920s"
  92. Write-Host " B. 1950s"
  93. Write-Host " C. 1940s"
  94. Write-Host " D. 1930s"
  95. Write-Host
  96. $answers[1] = Read-Host "Type the letter representing the correct" `
  97. " answer and press the Enter key."
  98. }
  99.  
  100. # Ask the player the third question
  101. while ($valid -notcontains $answers[2]) {
  102.  
  103. Clear-Host # Clear the Windows command console screen
  104.  
  105. Write-Host
  106. Write-Host $question3
  107. Write-Host
  108. Write-Host " A. The Spanish-American War"
  109. Write-Host " B. The Boer War"
  110. Write-Host " C. The Spanish Civil War"
  111. Write-Host " D. The Korean War"
  112. Write-Host
  113. $answers[2] = Read-Host "Type the letter representing the correct" `
  114. " answer and press the Enter key."
  115. }
  116.  
  117. # Ask the player the fourth question
  118. while ($valid -notcontains $answers[3]) {
  119.  
  120. Clear-Host # Clear the Windows command console screen
  121.  
  122. Write-Host
  123. Write-Host $question4
  124. Write-Host
  125. Write-Host " A. The Munich Conference"
  126. Write-Host " B. The 1936 Olympic Conferences"
  127. Write-Host " C. The Washington Naval Conference"
  128. Write-Host " D. The Geneva Convention"
  129. Write-Host
  130. $answers[3] = Read-Host "Type the letter representing the correct" `
  131. " answer and press the Enter key."
  132. }
  133.  
  134. # Ask the player the fifth question
  135. while ($valid -notcontains $answers[4]) {
  136.  
  137. Clear-Host # Clear the Windows command console screen
  138.  
  139. Write-Host
  140. Write-Host $question5
  141. Write-Host
  142. Write-Host " A. Pearl Harbor"
  143. Write-Host " B. Assassination of Arch Duke Ferdinand"
  144. Write-Host " C. Invasion of Poland"
  145. Write-Host " D. Battle of Britain"
  146. Write-Host
  147. $answers[4] = Read-Host "Type the letter representing the correct" `
  148. " answer and press the Enter key."
  149. }
  150.  
  151. # Clear the Windows command console screen
  152. Clear-Host
  153.  
  154. Write-Host
  155. Write-Host " OK, now press the Enter key to see how you did."
  156.  
  157. # Pause script execution and wait for the player to press the Enter key
  158. Read-Host
  159.  
  160. # Clear the Windows command console screen
  161. Clear-Host
  162.  
  163. # Grade the answers for each quiz question
  164. if ($answers[0] -eq $correctAnswers[0]) { $noCorrect++ } # The answer to question 1 is "B"
  165. if ($answers[1] -eq $correctAnswers[1]) { $noCorrect++ } # The answer to question 2 is "D"
  166. if ($answers[2] -eq $correctAnswers[2]) { $noCorrect++ } # The answer to question 3 is "C"
  167. if ($answers[3] -eq $correctAnswers[3]) { $noCorrect++ } # The answer to question 4 is "A"
  168. if ($answers[4] -eq $correctAnswers[4]) { $noCorrect++ } # The answer to question 5 is "C"
  169.  
  170.  
  171. # Assign a ranking based on quiz score
  172. if (($noCorrect -eq 0) -or ($noCorrect -eq 1)){
  173. Write-Host
  174. Write-Host " You got 0-1 questions correct."
  175. Write-Host
  176. Write-Host " You're not very good at this."
  177. }
  178.  
  179. if (($noCorrect -eq 2) -or ($noCorrect -eq 3)) {
  180. Write-Host
  181. Write-Host " You got 2-3 question correct."
  182. Write-Host
  183. Write-Host " You know who could do better than you at this?" `
  184. "Your Mother!"
  185. }
  186.  
  187. if (($noCorrect -eq 4) -or ($noCorrect -eq 5)) {
  188. Write-Host
  189. Write-Host " You got 4-5 questions correct."
  190. Write-Host
  191. Write-Host " You think you can win?" `
  192. "so did Hitler..."
  193. }
  194.  
  195.  
  196. # Creates question and answer display
  197. Write-Host " Question 1 was: `n ", $question1 ," `n Your answer was: `n " $answers[0] " `n The correct answer was: `n " $correctAnswers[0] ," `n`n "
  198. Write-Host " Question 2 was: `n ", $question2 ," `n Your answer was: `n " $answers[1] ," `n The correct answer was: `n " $correctAnswers[1] ," `n`n "
  199. Write-Host " Question 3 was: `n ", $question3 ," `n Your answer was: `n " $answers[2] ," `n The correct answer was: `n " $correctAnswers[2] ," `n`n "
  200. Write-Host " Question 4 was: `n ", $question4 ," `n Your answer was: `n " $answers[3] ," `n The correct answer was: `n " $correctAnswers[3] ," `n`n "
  201. Write-Host " Question 5 was: `n ", $question5 ," `n Your answer was: `n " $answers[4] ," `n The correct answer was: `n " $correctAnswers[4] ," `n`n "
  202. Write-Host " Question 6 was: `n ", $question6 ," `n Your answer was: `n " $answers[5] ," `n The correct answer was: `n " $correctAnswers[5] ," `n`n "
  203.  
  204.  
  205. # Pause the script execution and wait for the player to press the Enter key
  206. Read-Host
  207.  
  208. # Clear the Windows command console screen.
  209. Clear-Host
  210.  
  211. # Provide the player with instructions
  212. Write-Host
  213. Write-Host " Thanks for taking the World War II Trivia Quiz!"
  214.  
  215. # Pause script execution and wait for the player to press the Enter key
  216. Read-Host
  217.  
  218.  
  219. # Clear the Windows command console screen
  220. Clear-Host
Advertisement
Add Comment
Please, Sign In to add comment