Have you made a mistake where you've declared too many or too few variables? What was the problem, and how did you fix it? When you begin writing a program, how do you know how many variables you'll need?
I forgot which program it was but I had two same variables and one of the variables was writing over the second one. I fixed it by deleting the variable that was writing over the other.
When you programmed the Princess Quiz, you needed several variables, one for each princess's score. For other programs, like the choose your own adventure program or the Marvel Universe Guesser, you only need one or two. What's the difference? What's a good rule of thumb for when you have to have a handful of variables versus when you only need one?
A good rule of thumb is named each variable with clear content. If one variable is the player then name the variable player.
No comments:
Post a Comment