| Home | Forums | What's new | Resources | |
| C++ |
| RitualOfTheTrout - Dec 5, 2003 |
| RitualOfTheTrout | Dec 5, 2003 | ||
| What i want to happen is that it evaluates the first if.. then if its false it moves on tot he second if.. and so on.. but i dont know why runs all the else statements? | |||
| mtxblau | Dec 5, 2003 | |||
| Shouldn't you use a case1, case2, case3 set-up? The reason why it's evaluating every else is because since both values aren't met, it'll automatically go to the else, for all of them. What you may want to do is use a do - while loop for each (or so I think - what do I know?). EDIT: Looking at it, you may just want to do a nested if loop. Code:
It's not pretty, but you get the job done. Since the two variables you're passing are rarely going to match (probably not ever, since it won't evaluate the if) it'll always evaluate the else. | ||||
| RitualOfTheTrout | Dec 5, 2003 | |||
| I fixed it... it's probably not the most effecient way in the least, but it does what I want. The main goal is to test our use of Rose, not C++ knowledge... so in this case, a little bad programming shouldn't hurt me hehe... Code:
| ||||
| Mask of Destiny | Dec 6, 2003 | ||
| You can take out one of the conditions in your else ifs. | |||
| antime | Dec 6, 2003 | ||
| Only the amount check, or you'll get extra log messages if an item has run out before. MTXBlau's suggestion is cleaner. Personally I'd put the items in an array or list so you'd get by with only one check. | |||