Answer:
class fan{
private String model;
private boolean isOn;
//Constructor goes here
public fan(String model, boolean isOn) {
this.model = model;
this.isOn = isOn;
}
// An additional method goes here
public boolean turnOn(boolean yes){
if(yes) {
this.isOn=true;
System.out.println("Fan is blowing");
return true;
}
else
this.isOn=false;
System.out.println("Fan is off");
return false;
}
}
Explanation:
Demonstrating the working of the class in a main method. Below is a complete code
public class fanTest {
public static void main(String[] args) {
fan fan1 = new fan("Binatone", false);
fan1.turnOn(false);
}
}
class fan{
private String model;
private boolean isOn;
//Constructor goes here
public fan(String model, boolean isOn) {
this.model = model;
this.isOn = isOn;
}
// An additional method goes here
public boolean turnOn(boolean yes){
if(yes) {
this.isOn=true;
System.out.println("Fan is blowing");
return true;
}
else
this.isOn=false;
System.out.println("Fan is off");
return false;
}
}