Computer Science Canada how to make a counter? |
Author: | battleroyale [ Fri Apr 15, 2005 4:55 pm ] |
Post subject: | how to make a counter? |
OK......how do you make a counter for a lottery game or w/e. Like you have money and if you win you get w/e. and if you lose you lose w/e. plz help |
Author: | Delos [ Fri Apr 15, 2005 5:29 pm ] | ||
Post subject: | |||
A 'counter' is a fancy name for a variable.
Oh, in case you're wondering, 'iAmNotACounter' is a counter. |
Author: | battleroyale [ Fri Apr 15, 2005 5:48 pm ] |
Post subject: | |
ok...how would i use that too make a score chart...like you start off with a number..and if you win..the number goes up..but if you lose the number goes down...can you use if statements? |
Author: | [Gandalf] [ Fri Apr 15, 2005 5:59 pm ] | ||
Post subject: | |||
Of course (and I showed the same thing as above on your previous post ![]()
|
Author: | battleroyale [ Fri Apr 15, 2005 6:27 pm ] | ||||
Post subject: | |||||
sorry gandalf for using up your time...ill stick with this thread now.. ok...for your code
how would i start it...cuz i dont know how to declare result (cuz im a noob ![]()
I want to add somewhere the money you start off with ($5) and if you win..you add 10 bucks and if you lose you lose a buck (or w/e) the stuff that iv tried kept resetting the start money to 5....help ps. as you can see...i dont understand arrays so its really long and repetitive... |
Author: | [Gandalf] [ Fri Apr 15, 2005 7:06 pm ] | ||||
Post subject: | |||||
To declare you use something like this result := "win" after already identifying result as a string. So, for an example:
Try adapting that to your program. Also, to make your program more efficient and neat when declaring many similar variables use this:
Or later on, to improve this idea further research arrays, you might want to check one of the tutorials for that. Hope this helps! |
Author: | battleroyale [ Sat Apr 16, 2005 12:36 pm ] |
Post subject: | |
thanks..it did...all i need to do is clean it up and add some colour... THANKS again |
Author: | shlitiouse [ Mon Apr 18, 2005 8:22 am ] | ||
Post subject: | |||
Hi, I noticed that you had asked about giving the user a set amount of money that they could use, I read through the advice and didn't see anyone mention anything about it. It would just be a simple question of adding
This is basicaly what you were doing before, except you're giving the variable a set number. If you want to make the game a little more interesting, you could make different difficulty levels that would let the user start out with more or less money, depending on the difficulty selected. This can be done with a "difficulty" variable, a couple more IF statements, and a get statement at the beggining. I'll let you have fun trying out these suggestions, rather than posting how to do it. But if you get stuck feel free to ask[/code] |
Author: | [Gandalf] [ Mon Apr 18, 2005 9:57 pm ] | ||
Post subject: | |||
Ya, if you looked more closely you would see I did have that. Quote: var score : int := 10
score += 10 %etc, etc... Anyways, if you did want to have a difficulty setting, or just allow the user to input the amount of starting money then (according to my code):
and then just work with that, its pretty simple once you understand it... Now I suggest you look up arrays - the earlier you learn them the less trouble you're going to have (trust me ![]() |