Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function drawnumber([int]$min,[int]$max)
- {
- return get-random -Minimum $min -Maximum $max
- }
- function guess()
- {
- Write-Host -NoNewline “What is the number? “
- $Guess = [int] (Read-Host)
- checkguess
- }
- function checkguess()
- {
- If ($Guess -gt $Number) {
- Write-Host “$Guess is too high.”
- guess
- }
- ElseIf ($Guess -lt $Number) {
- Write-Host “$Guess is too low.”
- guess
- }
- }
- function startgame()
- {
- [int] $numberofguesses = 0
- [int] $Number = drawnumber 1 100
- [int] $Guess = 0
- Write-Host “I’m thinking of a number between 1 and 100. Can you guess it??;)”
- guess
- }
- startgame
- $continue = "yes"
- While ($continue -ne "n" -and $continue -ne "no") {
- $continue = Read-Host -Prompt "Do you want to play again?"
- if ($continue -ne "n" -and $continue -ne "no"){
- startgame
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement