Computer Science Canada bugged guessing game |
Author: | ssr [ Sat Oct 23, 2004 7:42 pm ] |
Post subject: | bugged guessing game |
hello ever1, I just made a guessing game, however, there is a bug in it, that is whenever you guess the number right the first time, it asks you twice if you want to continue, it is caused by the loop, I think. can any1 help me? |
Author: | Delos [ Sat Oct 23, 2004 10:16 pm ] | ||||
Post subject: | |||||
Ok...your code really is buggy. You have a lot of redundancy in it, for example
You don't need the "= true" part. strintok is a boolean function, thus it returns true/false as it is...
If you're resetting 'count', just use "count := 3" instead. And then again, why you have 'count' is a mystery, you're using a for loop thus the number of times it loops is already counted. When an answer is guessed correctly, before the count extinguishes, one is prompted with the desicion to exit or not. This doesn't actually work...if you want to exit, it still keeps you in the main loop. My suggestion for this is to reconsider how you've structured your programme. If you're going to use 'count' then don't bother with the for loop. It adds an extra level of unnecassary complexity to your programme that could quite simply be made without it. |
Author: | Hikaru79 [ Sat Oct 23, 2004 11:42 pm ] | ||
Post subject: | |||
Here's a streamlined and WORKING version of your code. I rewrote it but tried to use as much recycled code from your program as I could. All I ask is that if you are handing this code in you CAREFULLY look it over and make sure you UNDERSTAND my code. Good luck!
|
Author: | Andy [ Sun Oct 24, 2004 1:28 pm ] |
Post subject: | |
err ur code would crash if they give an invalid input |