So i have these if statements and I have 2 questions. First is there a way to combine these statement to make 1 big if condition. Also, I was wondering if there was a way to make it so if the condition is true then automatically end the method. I don't actually want to say "no freight train" I want to end the method if the if statement are true.
public void rule4(ArrayList<Integer> dierolled){
if (dierolled.contains(1)){
System.out.println("no freight train");
}
if (dierolled.contains(3)){
System.out.println("no freight train");
}
if (dierolled.contains(10)){
System.out.println("no freight train");
}
}
To combine if statements, try this:
The above is essentially saying this: If dierolled contains 1 OR dierolled contains 3 OR dierolled contains 10 then print "no freight train"
The above is essentially saying this: If dierolled contains 1 AND dierolled contains 3 AND dierolled contains 10 then print "no freight train"
To end the method, simply add
return;