Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a class AirConditioner that supports the following behaviors: turning the air co

ID: 440236 • Letter: A

Question

a class AirConditioner that supports the following behaviors: turning the air conditioner on and off, setting the desired temperature, and reporting the previously set temperature. The following methods provide this behavior: turnOn and turnOff , setTemp , which accepts an int argument and returns no value, and getTemp , which accepts no value and returns an int . Assume there is a reference variable myAC to an object of this class, which has already been created. There is also an int variable called currentTemp , which has already been declared. Use the reference variable, to invoke a method to retrieve the previously set temperature and store the returned value in currentTemp .

Explanation / Answer

1.  Write the code for invoking a method named sendSignal.  There are no arguments for this method. Assume that sendSignal is defined in the same class that calls it. sendSignal() ; 2.  Write the code for invoking a method named sendNumber.  There is one int argument for this method. Send the number 5 as an argument to this method. Assume that sendNumber is defined in the same class that calls it. sendNumber(5) ; 3.  Write the code for invoking a method named  sendVariable.  There is one int argument for this method. Assume that an int variable called x has already been declared and initialized to some value.  Use this variable's value as an argument in your method invocation. Assume that sendVariable is defined in the same class that calls it. sendVariable(x) ; 4.  Write the code for invoking a method named sendTwo.  There are two arguments for this method:  a double and an int.  Invoke the method with the double value of 15.955 and the int value of 133. Assume that sendTwo is defined in the same class that calls it. sendTwo(15.955,133) ; 5.  Write the code for invoking a method named sendObject.  There is one argument for this method which is of type Customer. Assume that there is a reference to an object of type Customer, in a variable called John_Doe.  Use this reference as your argument. Assume that sendObject is defined in the same class that calls it. sendObject(John_Doe) ; Sending_Messages 1.  Assume there is a class AirConditioner that supports the following behaviors:  turning the air conditioner on and off.  The following methods are 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. Example:  So, as a result of your code executing, the turnOn() method of the AirCondition object that myAC refers to will be invoked. myAC.turnOn() ; 2.  Assume there is a class AirConditioner that supports the following behaviors:  turning the air conditioner on and off.  The following methods are 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 objection to turn off. myAC.turnOff() ; 3.  Assume there is a class AirConditioner that supports the following behaviors:  turning the air conditioner on and off, and setting the desired temperature.  The following methods provide this behavior:  turnOn and turnOff, and setTemp, which accepts an int argument and returns no value. Assume there is a reference variable myAC to an object of this class, which has already been created. Use the reference variable, to invoke a method that tells the object to set the air conditioner to 72 degrees. myAC.setTemp(72) ; 4.  Assume there is a class AirConditioner that supports the following behaviors:  turning the air conditioner on and off, setting the desired temperature, and reporting the previously set temperature. The following methods provide this behavior:  turnOn and turnOff, setTemp, which accepts an int argument and returns no value, and getTemp, which accepts no value and returns an int. Assume there is a reference variable myAC to an object of this class, which has already been created. There is also an int variable called currentTemp, which has already been declared.  Use the reference variable, to invoke a method to retrieve the previously set temperature and store the returned value in currentTemp. currentTemp = myAC.getTemp() ; 5.  Assume there is a class AirConditioner that supports the following behaviors:  turning the air conditioner on and off, and checking if the air conditioner is on or off. The following methods provide this behavior:  turnOn and turnOff, setTemp, and isOn, which accepts no argument and returns a boolean indicating whether the air conditioner is on or off. Assume there is a reference variable myAC to an object of this class, which has already been created. There is also a boolean variable status, which has already been declared.  Use the reference variable, to invoke a method to find out whether the air conditioner is on and store the result in status. status = myAC.isOn() ; 6.  Assume there is a class AirConditioner that supports the following behaviors:  turning the air conditioner on and off.  The following methods provide these behaviors:  turnOn and turnOff.  Both methods accept no arguments and return no value. Assume there is a reference variable officeAC of type AirConditioner.  Create a new object of type AirConditioner and save the reference in officeAC.  After that, turn the air conditioner on using the reference to the new object. officeAC = new AirConditioner() ; officeAC.turnOn() ; 7.  Assume there is a class AirConditioner that supports the following behaviors:  turning the air conditioner on and off, and setting the desired temperature.  The following methods provide these behaviors:  turnOn and turnOff, which accept no arguments and return no value, and setTemp, which accepts an int argument and returns no value. Assume there is a reference variable officeAC of type AirConditioner.  Create a new object of type AirConditioner and save the reference in officeAC.  After that, use the reference to turn on the new air conditioner object and set the desired temperature to 69 degrees. officeAC = new AirConditioner() ; officeAC.turnOn() ; officeAC.setTemp(69) ;
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote