Ask Question

Assume there is a class AirConditioner that supports the following behaviors: turning the air conditioner on and off. The following methods provide this behavior: turnOn and turnOff. Both methods take no arguments and return no value.

Assume there is a reference variable myAC to an object of this class, which has already been created. Using the reference variable, invoke a method to tell the air conditioner object to turn on.

+2
Answers (1)
  1. 23 September, 15:19
    0
    Hi!

    I will use JAVA to answer the question.

    The class AirConditioner could be:

    public class AirConditioner {

    bolean state;

    AirConditioner () { / /constructor

    this. state = false;

    }

    public void turnOff{ / /turn off method

    this. state = false;

    }

    public void turnOn{ / /turn on method

    this. state = true;

    }

    }

    Program to solve the problem:

    public static void main () { / /main program

    AirConditioner myAC = new AirConditioner (); / /instanciate the AirConditioner object

    myAC. turnOn (); / /call the method turnOn for myAC instance.

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Assume there is a class AirConditioner that supports the following behaviors: turning the air conditioner on and off. The following methods ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers