I just can't figure out this problem and the assignment is due tonight!
Here is the prompt.
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.
public static void officeAC() {
AirConditioner officeAC = new AirConditioner();
officeAC.turnOn();
officeAC.setTemp(69);
}
I used a method, because you didn't specify wheather you wanted it in a class or what. You could do it in many way's use super class AirConditoinar with subclass's that extend it, like officeAC, and gymAC etc.. But, this would go right inside the same class.
Code:
public AirConditioner(boolean On, int Temp) {
}
public static void officeAC() {
AirConditioner officeAC = new AirConditioner(true, 69);
// other expressions you want for officeAC
}
You could do that if you the AirConditioner construct was set with arguments for it's temp, and being on or off.
Last edited by kolt007; October 6th, 2011 at 03:08 PM.
@kolt007 Please don't try to do peoples homework for them, it benefits no one.
@1sordnaskela The general rule here is if you just post your homework question you get no help. If you ask a specific question about your homework question or better still show some code then we will help.
Bookmarks