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]
3 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]3 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
30 points
Murljashka [212]
The answers are Library Catalog access, Simultaneous access, 24/7 availability, and database resources. No physical boundary and systems are also viable options but brick and mortar access is definetely not one.
3 0
3 years ago
Alice's public key, and sends back the number R encrypted with his private key. Alice decrypts the message and verifies that the
Agata [3.3K]

There are different kinds of keys. The identities of Alice and Bob are verified in this protocol.

<h3>What is public and private key in SSL?</h3>

These keys are known to be a kind of related pair of text files and they are often made together as a pair if one makes their Certificate Signing Request (CSR).

Note that the private key is different file that is often used in the encryption/decryption of data so as to sent a file between one's server and the connecting clients.

Learn more about  public/private key from

brainly.com/question/8782374

3 0
2 years ago
A standardized specification of a motherboard (including its dimensions, supported power supply types, and layout of components)
Alik [6]
The correct answer is 'Form Factor'. The standardized specification of a motherboard ( including it's dimensions, supported power supply types, and layout of components) is know as the motherboard's form factor.
5 0
4 years ago
What block cipher mode of operation uses the most basic approach where the plaintext is divided into blocks, and each block is t
Orlov [11]

Answer:

Electronic Code Book

Explanation:

5 0
3 years ago
_____ are used by teams of developers to manage changes to the code, so that changes are not lost or overwritten.
Amiraneli [1.4K]

In order to manage changes to a code, so that changes are not lost or overwritten, teams of developers use: <em>End-user license agreements</em>.

<h3>What is the End-User License Agreement (EULA)?</h3>

The End-User License Agreement (EULA) can be defined as a contract that dictates the rights a user has to use a software application in such a way that it protects the software vendor's intellectual property (IP).

Thus, in order to manage changes to a code, so that changes are not lost or overwritten, teams of developers use: <em>End-user license agreements</em>.

Learn more about End-user license agreements on:

brainly.com/question/24288054

7 0
2 years ago
Other questions:
  • Which option represents the location of the Data Table function?
    12·1 answer
  • The ________ defines every object and element on a web page.
    13·1 answer
  • What are the examples of shareware?
    9·2 answers
  • 14.18 Lab 5d - Nested Looping Write a program that:
    10·1 answer
  • A store that has both an e-commerce site as well as a physical store (building) is known as:
    8·1 answer
  • H&amp;R Block's stated purpose is: to be the leading global consumer tax company bringing tax and related solutions to clients y
    15·1 answer
  • When you use information hiding by selecting which properties and methods of a class to make public, you are assured that your d
    14·1 answer
  • According to the passage, what are the goals of the<br> program? Check all that apply.
    11·1 answer
  • What does route print do?
    15·1 answer
  • Match the data types to the types of value they are: Currency, Text, Date/time, and Name.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!