From the concepts we learned that we have:


General Form

The condition must evaluate to true/false. The code block can be any code.
public void play() {
	if (YOUR-CONDITION) {
		YOUR-CODE
	}
}
With Condition True

Here we hard-code the condition to true, so we do yes print.
public void play() {
	if (true) {
		prn("I am in the true block!");
	}
}
With Condition False

Here we hard-code the condition to false, so we do not print.
public void play() {
	if (false) {
		prn("Nuts, I never get here!");
	}
}
Using Vars

We'll often use variable(s) in the condition, in this case a method param var.
public void play(boolean isFun) {
	if (isFun) {
		prn("Yes Fun");
	}
}
Using Logical Expression

Here we use a logical expression in the condition (evaluates to true/false)
public void logicPlay() {
	int a=10, b=15;
	//If a < b, print
	if (a < b) {
		prn("a is smaller");
	}
}
Using Logical Operator

Java uses && and || for logical AND and OR
public void logicPlay() {
	int a=502, b=205;
	//if a > 500 AND b < 300
	if ((a > 500) && (b > 300)) {
		prn("Both conditions true");
	}
}
With Proper Objects

We'll often use proper objects in both the condition and the code block.
public void drawSquare(Rectangle rec,  Graphics g, Color c) {
	//If rec is a square, ask it to draw
	if (rec.isSquare()) {
		rec.draw(g, c);
	}
}