I would like to play a simple interrogation game. The suspect is a and b, both testifying to be true, or true if both are false testimony. If one is witnessing the truth, but the other is witnessing a lie, False. I would like to make a program like this.
First, define the method.
def investigation(a, b)
end
After that, it seems good to describe the conditional branch. We will describe by combining the following logical operators.
#true if both a and b are true
a && b
#true if either a or b is true
a || b
#false if a is true, true if a is false
!a
We will describe the conditional branch processing.
def investigation(a, b)
if (a && B ) || (!a && !b)
puts "True"
else
puts "False"
end
end
You have now created a game.
Recommended Posts