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
"what do you perform when you want to recall specific records from a database"
Ivan
A select query


select column1, column2, columnN
from table
where condition
order to be pretty;
5 0
3 years ago
Disadvantages assembly level language for programming ​
Alisiya [41]
It takes a lot of time and effort to write the code for the same. It is very complex and difficult to understand. The syntax is difficult to remember. It has a lack of portability of program between different computer architectures.

Hope that helps
7 0
3 years ago
Read 2 more answers
In distributed dos attacks, the attacker sends messages directly to ________. bots the intended victim of the dos attack backdoo
kirill115 [55]
The word DoS refers to the Disk Operating System. In the case given above, if it happens that there is a distributed DoS attack, the attacker then sends messages directly to the BOTS. Bots refer to internet or web robots. Hope this answer helps. The answer is the first option.
4 0
3 years ago
3. What report shows what mobile devices were used to view a website?
mrs_skeptik [129]

The report that shows what mobile devices were used to view a website is the Devices report under “Mobile”

<h3>What is a mobile device?</h3>

This is known to be a is a small hand-held device that shows screen with touch input and it is said to be also made up of QWERTY keyboard as well as others.

Note that The report that shows what mobile devices were used to view a website is the Devices report under “Mobile”

See full question below

What report shows what mobile devices were used to view a website?

The Exit Pages report under “Site Content”

The Landing Page report under “Site Content”

The Engagement report under “Behavior”

The Devices report under “Mobile”

Learn more about website from

brainly.com/question/13171394

#SPJ12

4 0
2 years ago
You check the ip address on a host on the network. the address is 122.16.155.71 with a mask of 255.0.0.0. what is the broadcast
Sveta_85 [38]
122.255.255.255






--------------------------------
8 0
3 years ago
Other questions:
  • Why did LISD had to block the game “among us”?
    8·2 answers
  • Explain how to use fortran programming in details
    14·1 answer
  • What are some of the issues that organizations need to be aware of when designing and managing data?
    8·1 answer
  • There is an application which inputs hundred numbers from the user, if user enters a positive number it increments valid numbers
    6·1 answer
  • What are html documents also called?
    12·1 answer
  • question i need a real answer cuase i have a virus cuase off my borther and these are the notifacations i get and now these site
    11·1 answer
  • I’ll mark brainliest if correct
    10·1 answer
  • If you give an actual answer I'll give brainliest​
    13·2 answers
  • Explain mechanical computer ,electromechanical and electronic computer with example<br>​
    11·1 answer
  • Write steps for converting decimal to binary numbers?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!