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

Username:   Password: 
 RegisterRegister   
 How do I make the if statement boolean if I need it to be as an integer?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JLChow




PostPosted: Tue Nov 10, 2015 5:48 pm   Post subject: How do I make the if statement boolean if I need it to be as an integer?

What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>


What is the problem you are having?
<We are told to make a slot machine in class, so I decided to take it for a spin. Now I am stuck with this problem of not being able to do something. So I have my random integers put as a variable with the name "slot1" slot2" and "slot3", but now when I try to do "if slot1, slot2, slot3 = 1 then" "put "WINNER!" it will tell me that it has to be in boolean format. I don't know what to do now.

Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


var slot1 : int
var slot2 : int
var slot3 : int
var key : array char of boolean
Draw.Box (240, 181, 390, 211, black)
Draw.Box (235, 176, 395, 216, black)
loop
Input.KeyDown (key)
randint (slot1, 1, 3)
randint (slot2, 1, 3)
randint (slot3, 1, 3)
if key (KEY_ENTER) then
if slot1 = 1 then
Draw.FillOval (265, 196, 10, 10, yellow)
elsif slot1 = 2 then
Draw.FillOval (265, 196, 10, 10, red)
elsif slot1 = 3 then
Draw.FillOval (265, 196, 10, 10, blue)
if slot2 = 1 then
Draw.FillOval (315, 196, 10, 10, yellow)
elsif slot2 = 2 then
Draw.FillOval (315, 196, 10, 10, red)
elsif slot2 = 3 then
Draw.FillOval (315, 196, 10, 10, blue)
if slot3 = 1 then
Draw.FillOval (365, 196, 10, 10, yellow)
elsif slot3 = 2 then
Draw.FillOval (365, 196, 10, 10, red)
elsif slot3 = 3 then
Draw.FillOval (365, 196, 10, 10, blue)
end if
end if
end if
end if
end loop




Please specify what version of Turing you are using
<Answer Here>
Canada Canada Canada Canada
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Tue Nov 10, 2015 7:25 pm   Post subject: RE:How do I make the if statement boolean if I need it to be as an integer?

You need to test each slot individually and join them with the and keyword, like this:

code:
if slot1 = 1 and slot2 = 1 and slot3 = 1 then
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  [ 2 Posts ]
Jump to:   


Style:  
Search: