Computer Science Canada Scoring System |
Author: | MasterCard [ Sat Jun 27, 2015 2:39 pm ] |
Post subject: | Scoring System |
I have three options WIN LOSE TIE I want to make a score system, so the first one to 5 points wins the game! How do i do this? At the end of a round i put win lose or tie... so i want it so that after it says you have x points and computer has y points. |
Author: | Insectoid [ Sat Jun 27, 2015 5:24 pm ] |
Post subject: | RE:Scoring System |
Presumably your game is in a loop. So you need to exit the loop when the player's score is greater than 5, or when the computer's score is greater than 5. if the player's score is 5 and the computer's score is 5 then put tie. if the player's score is 5, put win. If the computer's score is 5, put lose. Then put "you have {player's score} points and computer has {computer's score} points. Your question translates almost word for word into code. It's an extremely basic application of if statements and the exit when statement. |
Author: | MasterCard [ Sun Jun 28, 2015 12:36 am ] |
Post subject: | RE:Scoring System |
How do i add a point to a variable? |
Author: | Insectoid [ Sun Jun 28, 2015 3:45 am ] |
Post subject: | RE:Scoring System |
What is a point? |
Author: | TokenHerbz [ Sun Jun 28, 2015 4:09 pm ] |
Post subject: | RE:Scoring System |
variable += point |
Author: | MasterCard [ Sun Jun 28, 2015 10:03 pm ] |
Post subject: | RE:Scoring System |
How do i +1 to the number that the variable holds |
Author: | Insectoid [ Sun Jun 28, 2015 10:18 pm ] | ||
Post subject: | RE:Scoring System | ||
You can just make it equal itself plus one. foo := foo + 1 Doesn't make sense in math notation, but in programming it's just fine. This operation so common that Turing (and most other languages) built in the += operator, so
It's that easy. |