Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # **********************************************************************
- #
- # Script Name: WWII.ps1 (World War II Trivia Quiz)
- # Version: 2.0
- # Author: Paul Ferguson
- # Date: September 23, 2015
- #
- # Description: This PowerShell script tests the player's knowledge
- # of World War II trivia through the administration of
- # a computer quiz made up of 5 questions.
- #
- # **********************************************************************
- # Clear the Windows command console screen
- Clear-Host
- # Define the array used in this script to store questions
- $question1 = " What was the treaty that ended WWI that laid some of the unrest that would later explode into WWII?"
- $question2 = " Hitler became the essential dictator of Germany in which decade?"
- $question3 = " What war during the 1930s greatly influenced the development of military tactics that were used in WWII?"
- $question4 = " What was the last major attempt at a peaceful resolution with Germany prior to the outbreak of WWII?"
- $question5 = " What event began World War II?"
- # Define the array used in this script to store player answers
- $answers = "","","","","","","","","",""
- # Define the array used in this script to store valid answers
- $valid = "a","b","c","d"
- # Define the array used in this script to store correct answers
- $correctAnswers = "b","d","c","a","c",
- # Define a variable to keep track of the number of correctly answered quiz questions
- $noCorrect = 0
- # Display the game's opening screen
- Write-Host "`n`n`n`n`t`t W E L C O M E T O T H E "
- Write-Host "`n`n`n`t`t`t W O R L D W A R T R I V I A"
- Write-Host "`n`n`n`t`t`t`t By Paul Ferguson"
- Write-Host "`n`n`n`n`n`n`n`n`n`n Press Enter to continue."
- # Pause script execution and wait for the player to press the Enter key
- Read-Host
- # Clear the Windows Command Console Screen
- Clear-Host
- # Provide the player with instructions
- Write-Host "`n`n The World War Trivia Quiz tests your knowledge of Seinfeld`n"
- Write-Host " trivia. The quiz consists of five equally weighted multiple`n"
- Write-Host " choice questions. At the end of the quiz your answers will`n"
- Write-Host " be checked and you will be assigned a skill level, using`n"
- Write-Host " the following scale.`n`n"
- Write-Host " `t Score: 5 correct = Invasion of Poland"
- Write-Host " `t`t 6-7 correct = The Munich Conference"
- Write-Host " `t`t 4-5 correct = The Spanish Civil War"
- Write-Host " `t`t 2-3 correct = 1930s"
- Write-Host " `t`t 0-1 correct = Treaty of Versailles"
- Write-Host "`n`n`n`n Press Enter to continue."
- # Pause script execution and wait for the player to press the Enter key
- Read-Host
- # Ask the player the first question
- while ($valid -notcontains $answers[0]) {
- Clear-Host # Clear the Windows command console screen
- Write-Host
- Write-Host $question1
- Write-Host
- Write-Host " A. Geneva Conference"
- Write-Host " B. Treaty of Versailles"
- Write-Host " C. Paris Peace Accords"
- Write-Host " D. Treaty of Brest-Litovsk"
- Write-Host
- $answers[0] = Read-Host "Type the letter representing the correct" `
- " answer and press the Enter key."
- }
- # Ask the player the second question
- while ($valid -notcontains $answers[1]) {
- Clear-Host # Clear the Windows command console screen
- Write-Host
- Write-Host $question2
- Write-Host
- Write-Host " A. 1920s"
- Write-Host " B. 1950s"
- Write-Host " C. 1940s"
- Write-Host " D. 1930s"
- Write-Host
- $answers[1] = Read-Host "Type the letter representing the correct" `
- " answer and press the Enter key."
- }
- # Ask the player the third question
- while ($valid -notcontains $answers[2]) {
- Clear-Host # Clear the Windows command console screen
- Write-Host
- Write-Host $question3
- Write-Host
- Write-Host " A. The Spanish-American War"
- Write-Host " B. The Boer War"
- Write-Host " C. The Spanish Civil War"
- Write-Host " D. The Korean War"
- Write-Host
- $answers[2] = Read-Host "Type the letter representing the correct" `
- " answer and press the Enter key."
- }
- # Ask the player the fourth question
- while ($valid -notcontains $answers[3]) {
- Clear-Host # Clear the Windows command console screen
- Write-Host
- Write-Host $question4
- Write-Host
- Write-Host " A. The Munich Conference"
- Write-Host " B. The 1936 Olympic Conferences"
- Write-Host " C. The Washington Naval Conference"
- Write-Host " D. The Geneva Convention"
- Write-Host
- $answers[3] = Read-Host "Type the letter representing the correct" `
- " answer and press the Enter key."
- }
- # Ask the player the fifth question
- while ($valid -notcontains $answers[4]) {
- Clear-Host # Clear the Windows command console screen
- Write-Host
- Write-Host $question5
- Write-Host
- Write-Host " A. Pearl Harbor"
- Write-Host " B. Assassination of Arch Duke Ferdinand"
- Write-Host " C. Invasion of Poland"
- Write-Host " D. Battle of Britain"
- Write-Host
- $answers[4] = Read-Host "Type the letter representing the correct" `
- " answer and press the Enter key."
- }
- # Clear the Windows command console screen
- Clear-Host
- Write-Host
- Write-Host " OK, now press the Enter key to see how you did."
- # Pause script execution and wait for the player to press the Enter key
- Read-Host
- # Clear the Windows command console screen
- Clear-Host
- # Grade the answers for each quiz question
- if ($answers[0] -eq $correctAnswers[0]) { $noCorrect++ } # The answer to question 1 is "B"
- if ($answers[1] -eq $correctAnswers[1]) { $noCorrect++ } # The answer to question 2 is "D"
- if ($answers[2] -eq $correctAnswers[2]) { $noCorrect++ } # The answer to question 3 is "C"
- if ($answers[3] -eq $correctAnswers[3]) { $noCorrect++ } # The answer to question 4 is "A"
- if ($answers[4] -eq $correctAnswers[4]) { $noCorrect++ } # The answer to question 5 is "C"
- # Assign a ranking based on quiz score
- if (($noCorrect -eq 0) -or ($noCorrect -eq 1)){
- Write-Host
- Write-Host " You got 0-1 questions correct."
- Write-Host
- Write-Host " You're not very good at this."
- }
- if (($noCorrect -eq 2) -or ($noCorrect -eq 3)) {
- Write-Host
- Write-Host " You got 2-3 question correct."
- Write-Host
- Write-Host " You know who could do better than you at this?" `
- "Your Mother!"
- }
- if (($noCorrect -eq 4) -or ($noCorrect -eq 5)) {
- Write-Host
- Write-Host " You got 4-5 questions correct."
- Write-Host
- Write-Host " You think you can win?" `
- "so did Hitler..."
- }
- # Creates question and answer display
- Write-Host " Question 1 was: `n ", $question1 ," `n Your answer was: `n " $answers[0] " `n The correct answer was: `n " $correctAnswers[0] ," `n`n "
- Write-Host " Question 2 was: `n ", $question2 ," `n Your answer was: `n " $answers[1] ," `n The correct answer was: `n " $correctAnswers[1] ," `n`n "
- Write-Host " Question 3 was: `n ", $question3 ," `n Your answer was: `n " $answers[2] ," `n The correct answer was: `n " $correctAnswers[2] ," `n`n "
- Write-Host " Question 4 was: `n ", $question4 ," `n Your answer was: `n " $answers[3] ," `n The correct answer was: `n " $correctAnswers[3] ," `n`n "
- Write-Host " Question 5 was: `n ", $question5 ," `n Your answer was: `n " $answers[4] ," `n The correct answer was: `n " $correctAnswers[4] ," `n`n "
- Write-Host " Question 6 was: `n ", $question6 ," `n Your answer was: `n " $answers[5] ," `n The correct answer was: `n " $correctAnswers[5] ," `n`n "
- # Pause the script execution and wait for the player to press the Enter key
- Read-Host
- # Clear the Windows command console screen.
- Clear-Host
- # Provide the player with instructions
- Write-Host
- Write-Host " Thanks for taking the World War II Trivia Quiz!"
- # Pause script execution and wait for the player to press the Enter key
- Read-Host
- # Clear the Windows command console screen
- Clear-Host
Advertisement
Add Comment
Please, Sign In to add comment