Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function drawnumber([int]$min,[int]$max)
  2. {
  3.     return get-random -Minimum $min -Maximum $max
  4. }
  5.  
  6. function guess()
  7. {
  8.     Write-Host -NoNewline “What is the number?
  9.     $Guess = [int] (Read-Host)
  10.     checkguess
  11. }
  12.  
  13. function checkguess()
  14. {
  15.     If ($Guess -gt $Number) {
  16.         Write-Host$Guess is too high.”
  17.         guess
  18.     }
  19.     ElseIf ($Guess -lt $Number) {
  20.         Write-Host$Guess is too low.”
  21.         guess
  22.     }
  23. }
  24.  
  25. function startgame()
  26. {
  27.     [int] $numberofguesses = 0
  28.     [int] $Number = drawnumber 1 100
  29.     [int] $Guess = 0
  30.  
  31.     Write-Host “I’m thinking of a number between 1 and 100. Can you guess it??;)
  32.     guess
  33. }
  34.  
  35. startgame
  36.  
  37. $continue = "yes"
  38. While ($continue -ne "n" -and $continue -ne "no") {
  39.     $continue = Read-Host -Prompt "Do you want to play again?"
  40.     if ($continue -ne "n" -and $continue -ne "no"){
  41.         startgame
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement