Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Scoring System
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MasterCard




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: 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.
MasterCard




PostPosted: Sun Jun 28, 2015 12:36 am   Post subject: RE:Scoring System

How do i add a point to a variable?
Insectoid




PostPosted: Sun Jun 28, 2015 3:45 am   Post subject: RE:Scoring System

What is a point?
TokenHerbz




PostPosted: Sun Jun 28, 2015 4:09 pm   Post subject: RE:Scoring System

variable += point
MasterCard




PostPosted: Sun Jun 28, 2015 10:03 pm   Post subject: RE:Scoring System

How do i +1 to the number that the variable holds
Insectoid




PostPosted: 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
code:

foo := foo + 1
%is the same as
foo += 1


It's that easy.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: