Just making a silly program to work on my Powershell skills. The outer do...while works. I have even gotten the inner do...while to work, however instead of breaking both loops when the inner loop has been satisfied, it goes back to "Are you in a hurry? y/n:" I have tried moving the break(s) around to various different spots in the code and I have tried labels. Nothing seems to give me the results I am looking for. I understand there are probably ways a million times better to write this code and eventually I will look for ways to optimize. Right now, I am just trying to write the code in the way my mind works and to solve the problem - that is to say, no code rewrites please... unless what I am trying to do is impossible.
$resultArray = @("go", "not go")
# give result
$result = $resultArray | Get-Random
# text results to jason
# check if in hurry
do{
while ($get_in_hurry = read-host "Are you in a hurry? y/n:"){
# if in hurry, jump to spin
if ($get_in_hurry -eq "y") {
Write-Host "You seleted you are in a hurry."
Write-Host "My suggestion is to" $result "to poker with Jason tonight."
break
}
# if not in hurry ask questions
elseif ($get_in_hurry -eq "n") {
Write-Host "You seleted you are NOT in a hurry."
# check mood
do{
while ($get_mood = read-host "Are you in a good mood? y/n:") {
# if not in good mood, adjust percentage, and spin
if ($get_mood -eq "n") {
Write-Host "You seleted you are not in a good mood."
Write-Host "Write something funny"
$resultArray += "not go", "not go", "not go", "not go", "not go", "not go", "not go", "not go"
Write-Host "My suggestion is to" $result "to poker with Jason tonight."
break
}
# good mood, adjust percentage
elseif ($get_mood -eq "y") {
Write-Host "You seleted you are in a good mood."
break
}
# if mood not yes or no, request yes or no
else {
Write-Host "Please speak in english. Are in a good mood? y/n:"
}
}
# gone to poker in last month, adjust percentage
# jason ask to go in last two weeks, adjust percentage
# did you go, adjust percentage
# do math
}
while (($get_mood -eq $null) -or ($get_mood -eq ""))
}
# if hurry not yes or no, request yes or no
else {
Write-Host "Please speak in english. Are in a hurry. y/n:"
# save variable text to jason to update application to give better response to any funny answers that may be given
}
}
}
# if hurry null, request yes or no
while (($get_in_hurry -eq $null) -or ($get_in_hurry -eq ""))
whilecondition. That's not going to work as you may expect it to. 😉if($get_mood = read-host "Are you in a good mood? y/n:"){'yes'}else{'no'}yand once withn. Then you may get what I mean.