So for the final part of the final project we have to edit our flowcharts and pseudocode according to the teachers comments. My flowchart was fine (thank you Kerm) but my pseudocode could use a little help. I'm not entirely sure how to fix it either, so Kerm reminded me of this helpful site. Beforehand though, I will say I don't quite understand how to write loops. Flowcharting loops, yes...Writing them, not so much. And it wasn't something that neither the teacher or the book went into that much (in detail.)
The teachers comment on my pseudocode was:
While my pseudocode is as follows:
The teachers comment on my pseudocode was:
Quote:
Very good! The WHILE loop seems to be buried a little too deep in the logic. For example, in Main(), you have this IF/ELSE setup to either play again or end the game... but it will only execute once because it is not contained within any kind of loop.
All of the core pieces to this program are present and well-constructed!
All of the core pieces to this program are present and well-constructed!
While my pseudocode is as follows:
Quote:
start
Declarations
num pScore = 0
num x
string guess
string "Fox"
string correctAnswer
string "Play Again"
hints[5] = {"Computer: I am thinking of an animal that has fur. What animal is it?", "Computer: No. The animal has red fur. What is it?", "Computer: No. The animal is carnivorous. What is it?", "Computer: No. The animals young are called kits. What is it?", "Computer: No. The animal is said to have nine tails in legends. What is it?"}
animalGame()
endOfGame()
animalGame()
if "Play Again" = "Y"
animalGame()
else
endOfGame()
endif
end
animalGame()
hints[x]
input guess
if guess = "Fox" then
correctAnswer = "Y"
endif
if correctAnswer = "Y" then
pScore = pScore + 1
output "Computer: Correct."
return
else
x = x + 1
while x < 5
output hints[x]
input guess
endwhile
output "Computer: No. The answer was Fox."
return
endif
return
endOfGame()
output "Player's final score is ", pScore
return
Declarations
num pScore = 0
num x
string guess
string "Fox"
string correctAnswer
string "Play Again"
hints[5] = {"Computer: I am thinking of an animal that has fur. What animal is it?", "Computer: No. The animal has red fur. What is it?", "Computer: No. The animal is carnivorous. What is it?", "Computer: No. The animals young are called kits. What is it?", "Computer: No. The animal is said to have nine tails in legends. What is it?"}
animalGame()
endOfGame()
animalGame()
if "Play Again" = "Y"
animalGame()
else
endOfGame()
endif
end
animalGame()
hints[x]
input guess
if guess = "Fox" then
correctAnswer = "Y"
endif
if correctAnswer = "Y" then
pScore = pScore + 1
output "Computer: Correct."
return
else
x = x + 1
while x < 5
output hints[x]
input guess
endwhile
output "Computer: No. The answer was Fox."
return
endif
return
endOfGame()
output "Player's final score is ", pScore
return