This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -7,17 +7,17 @@ Function isNumeric ($x)
Return $isNum
}
$NumberOne = Random -Maximum 10 -Minimum 1
$NumberTwo = Random -Maximum 10 -Minimum 1
$NumberThree = Random -Maximum 10 -Minimum 1
$NumberFour = Random -Maximum 10 -Minimum 1
$NumberArray = @()
$NumberArray += $NumberOne
$NumberArray += $NumberTwo
$NumberArray += $NumberThree
$NumberArray += $NumberFour
While( $NumberArray.Count -lt 4 ){
$NumberArray += Random -Minimum 1 -Maximum 10
}
Write-Host "Welcome to the 24 game!`n`nHere are your numbers: $NumberOne,$NumberTwo,$NumberThree and $NumberFour.`nUse division, multiplication, subtraction and addition to get 24 as a result with these 4 numbers.`n"
Write-Host @"
Welcome to the 24 game!
Here are your numbers: $($NumberArray -join ",").
Use division, multiplication, subtraction and addition to get 24 as a result with these 4 numbers.
"@
Do
{
@ -26,50 +26,14 @@ $EndResult = $null
$TempChar = $null
$TempChar2 = $null
$Count = $null
$AllowableCharacters = $NumberArray + "+-*/()".ToCharArray()
$Result = Read-Host
Foreach($Char in $Result.ToCharArray())
{
Switch($Char)
{
$NumberOne
{
}
$NumberTwo
{
}
$NumberThree
{
}
$NumberFour
{
}
"+"
{
}
"-"
{
}
"*"
{
}
"/"
{
}
"("
{
}
")"
{
}
" "
{
}
Default
{
$Wrong = 1
}
}
If( $AllowableCharacters -notcontains $Char ){ $Wrong = 1 }
}
If($Wrong -eq 1)
{
Write-Warning "Wrong input! Please use only the given numbers."