When I run this code the value of the boolean snare is correctly reset from true to false, but the if
test ignores this and executes the code inside the if test.
This is the code as shown on page 44 of Head First
Java, so it should work.
Please assist.
Steve Janvrin.
class DrumKit {
boolean tophat = true;
boolean snare = true;
void playtophat() {
System.out.println("ding ding da-ding");
}
void playsnare() {
System.out.println("bang bang ba-bang");
}
}
class DrumKitTestDrive {
public static void main(
String[] args) {
DrumKit d = new DrumKit();
d.playsnare();
d.playtophat();
d.snare = false;
if (d.snare == true); {
d.playsnare();
}
}
}