Answer :
Answer:
public class AirConditioner {
boolean turnOnOff;
int temp;
//The Constructor
public AirConditioner(boolean turnOnOff, int temp) {
this.turnOnOff = turnOnOff;
this.temp = temp;
}
//Method to turnOn AC
public void turnOn(){
this.turnOnOff = true;
}
//Method to turnOff AC
public void turnOff(){
this.turnOnOff = false;
}
////Method to set Temperature
public void setTemp(int newTemp){
this.temp = newTemp;
}
}
Explanation:
A test class where an object of the class is created is given below
class AirconditionerTest{
public static void main(String[] args) {
//Creating the class reference
AirConditioner myAc = new AirConditioner(true,72);
//Calling methods in the class
myAc.turnOn();
myAc.setTemp(72);
}
}