Ask Question
Yesterday, 22:03

Suppose there is a class AirConditioner. The class supports the following behaviors: turning the air conditioner on and off. The following methods are provided for these behaviors: turn_on and turn_off. Both methods accept no arguments and return no value. There is a reference variable office_a_c of type AirConditioner. Create a new object of type AirConditioner using the office_a_c reference variable. After that, turn the air conditioner on using the reference to the new object.

+4
Answers (1)
  1. Yesterday, 22:49
    0
    The code is given in the explanation section

    Explanation:

    //Class Airconditioner

    public class AirConditioner {

    private boolean turnOnOff;

    //The Constructor

    public AirConditioner (boolean turnOnOff) {

    this. turnOnOff = turnOnOff;

    }

    //method turn_on

    public void turn_on () {

    this. turnOnOff = true;

    }

    //method turn_off

    public void turn_off () {

    this. turnOnOff = false;

    }

    }

    / / A new class to test the airconditional class

    class AircondionTest{

    public static void main (String[] args) {

    //Creating an object of the Aircondional class

    AirConditioner office_a_c = new AirConditioner (false);

    //Using the reference varible to call method turn_on

    office_a_c. turn_on ();

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Suppose there is a class AirConditioner. The class supports the following behaviors: turning the air conditioner on and off. The following ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers