View Single Post
  #3  
Old 02-09-2005, 12:06 AM
moondogg moondogg is offline
Senior Member
 
Join Date: Oct 2003
Posts: 145
Default Re: Java Help Needed

[ QUOTE ]
Little off topic but here goes. This is how I would do it.

private AirConditioner officeAC;

.
.
.

officeAC = new AirConditioner();
officeAC.turnOn();
officeAC.setTemp(69);

.
.
.

[/ QUOTE ]

One slight difference in how I read the question
[ QUOTE ]
There is a reference variable officeAC of type AirConditioner . Create a new object of type AirConditioner using the officeAC reference variable.

[/ QUOTE ]

//Assumed officeAC has already been defined and initialized

//Not sure this is valid Java syntax, but they do ask for a "new" object
AirConditioner myAC = new AirConditioner(officeAC);
//If this isn't valid, use AirConditioner myAC = officeAC;

//The rest is the same
officeAC.turnOn();
officeAC.setTemp(69);

Edit: P.S. I hate Java. Learn C++ or C#
Reply With Quote