How do I make the if statement boolean if I need it to be as an integer?
Author |
Message |
JLChow
|
Posted: 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](images/smiles/canada.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: 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 |
|
|
|
|
|
![](images/spacer.gif) |
|
|