turn on the airconditioner
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: turn on the airconditioner

  1. #1
    Join Date
    Oct 2011
    Posts
    1

    turn on the airconditioner

    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.

    Thanks in advance

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: turn on the airconditioner

    So what would you like us to do?
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    Join Date
    Sep 2011
    Posts
    197

    Re: turn on the airconditioner

    Code:
       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.

  4. #4
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: turn on the airconditioner

    @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.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  5. #5
    Join Date
    Sep 2011
    Posts
    197

    Re: turn on the airconditioner

    Sorry I am new so I dont know all the moore's of this social group.. I will keep this in mind.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center