Methods Summary |
---|
public void | clearStandardTires()Remove the standard tires option.
myCar.setOptions(myCar.getOptions() ^ Car.STANDARD_TIRES);
System.out.println(myCar.getOptions());
|
public static final void | main(java.lang.String[] args)Main Demo Method.
BitFieldDemo demo = new BitFieldDemo();
demo.setBitFields();
demo.clearStandardTires();
demo.printCarOptions();
|
public void | printCarOptions()Write the car's options to the console.
System.out.println("-- Options --");
if ((myCar.getOptions() & Car.POWER_WINDOWS) > 0) {
System.out.println("Power Windows");
}
if ((myCar.getOptions() & Car.POWER_LOCKS) > 0) {
System.out.println("Power Locks");
}
|
public void | setBitFields()Set the default options.
this.myCar = new Car();
myCar.setOptions(Car.CRUISE_CONTROL | Car.STANDARD_TIRES | Car.POWER_LOCKS);
System.out.println(myCar.getOptions());
|