1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NeX [460]
2 years ago
10

Suppose there is a class AirConditioner. The class supports the following behaviors: turning the air conditioner on and off. The

following methods are provided for these behaviors: turn_on and turn_off. Both methods accept no arguments and return no value.
"There is a reference variable my_ac to an object of this class, which has already been created. There is also a variable status, which has already been initialized which refers to a bool. Invoke a method of this object using the reference variable, asking the object to tell whether the air conditioner is on or off, and store the result in status."
Computers and Technology
1 answer:
Ksenya-84 [330]2 years ago
5 0

Answer:

Firstly, create an AirConditioner class inside a file named as AirConditioner.java. This is important to make sure the class name match with the file name.

  1. public class AirConditioner {
  2.    private boolean status = false;
  3.    public void turn_on()
  4.    {
  5.        this.status = true;
  6.    }
  7.    public void turn_off()
  8.    {
  9.        this.status = false;
  10.    }
  11.    public boolean getStatus()
  12.    {
  13.        return this.status;
  14.    }
  15. }

Next, create another file named as Main.java. This is where we are going to include a Main method to create an object of AirConditioner class and get the air conditioner status. The codes are as follows:

  1. public class Main {
  2.    public static void main(String[] args) {
  3.        AirConditioner my_ac= new AirConditioner();
  4.        boolean status;
  5.        my_ac.turn_on();
  6.        status = my_ac.getStatus();
  7.        System.out.println(status);
  8.    }
  9. }

Explanation:

The codes presented above are written based on the question requirements.

<u>AirConditioner.java</u>

Line 1:

  • Create an AirConditioner  class

Line 3:

  • A property status is defined. This is important to track the status of an AirConditioner object.

Line 5 -8 and Line 10 -13:

  • Create two required methods turn_on() and turn_off(). Both of them accept no arguments and return no value.
  • The only job done by this two methods is to change the status property to either true (on) or false (off).

Line 15 - 18:

  • The getStatus() method is to return the current status of the AirConditioner object to the Main method in main.java.

<u>Main.java</u>

Line 5-6:

  • Within the Main method, create an object of AirConditioner and assign it to a reference variable, my_ac
  • Create the status variable as a boolean variable.

Line 8:

  • Use reference variable my_ac to invoke turn_on() method to change the status of the AirConditioner object to true
  • Use the same reference variable my_ac to invoke getStatus() method to get the current satus of the AirConditioner object and assign it to the status variable.

Line 11:

  • Print the status of AirConditioner Object in terminal
You might be interested in
Outcomes resulting from using incorect requirement specification during system development​
Vlada [557]

Answer:

please give full understandable question buddy

5 0
3 years ago
Define function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print "Too small". If greater than
Oxana [17]

Answer:

def print_popcorn_time(bag_ounces):

 if bag_ounces<3:

    print("Too Small")

 elif bag_ounces>10:

   print("Too Large")

 else:

   total = 6*bag_ounces

   print('{} seconds'.format(total))

Explanation:

Using Python programming language

The function is defined to accept a single parameter

Using a combination of if/elif/else statements, the approprite message is displayed when the function is called

6 0
3 years ago
Which option helps you choose the design of a slide in a presentation?
lozanna [386]
Hello! The slide transition helps with the transitions of slides and the animation helps out with the words appearing on the screen in a more creative way. Therefore, C and D are out. The slide layout is the part where if you click on it, slide designs are shown for you to choose from. The shapes can be used for design, but it doesn't help if you're looking for the design of a slide. The answer is A: slide layout.
5 0
3 years ago
The IT person most involved with system development is the _________
laila [671]

Answer:

douch

Explanation:

3 0
3 years ago
A driving school uses this rule to estimate how many lessons a learner will require.
HACTEHA [7]

Answer:

This is correct. And to remove the confusion, I am adding the meaning of the Pseudocode. You need to begin with the algo that you are working upon, and then you need it to phrase the algo with the words which are easy to be transcribed in the form of the computer instructions. Now you need to indent the instructions properly inside the loop or within the conditional clauses. And while doing this, you need to not use the words which are used in certain forms of computer language. However, IF and THEN and ELSE and ENDIF are very frequently used as pseudo-code. Hence, your answer is correct.

Explanation:

Please check the answer section.

8 0
2 years ago
Other questions:
  • Employers will check you out on social media sites like Facebook, MySpace, and Twitter.
    6·2 answers
  • C - Language Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. E
    12·1 answer
  • Que funcion tiene la sombrilla forrada de aluminio​
    6·1 answer
  • Susan has always wanted to be a veterinarian. When doing her research, she answers all self-assessments geared toward that caree
    13·1 answer
  • Which of these is a Microsoft certification for system engineers?
    9·1 answer
  • It takes 2.5 yards of material to make a dress harleys clothing design estimates that they can produce 48 dresses each week.if t
    15·2 answers
  • Which of the following data structures can erase from its beginning or its end in O(1) time?
    15·1 answer
  • What is first page of website called​
    10·1 answer
  • How does digital and hybrid computers differ in portability​
    9·1 answer
  • Which of the following is NOT a method for applying the SDLC model?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!