Create a class named AirConditioner in its own file. (The main method should be in a different file.) The class should contain the following: Three public constants named HIGH, MEDIUM, and LOW with values of 1, 2, and 3 to denote the air conditioner fan speed. A private int data field named speed that specifies the speed of the air conditioner fan. (The default is 1 for high.) A private boolean data field named on that specifies whether the air conditioner is on or not. (The default is false.) A private double data field named temperature that specifies the temperature setting of the air conditioner. (The default is 72.0.) A private String data field named model that specifies the model name of the air conditioner. (The default is "Iceberg".) The accessor and mutator methods (getters and setters) for all four data fields. A no-arg constructor that creates a default air conditioner, with all the default settings. (Do not create a full constructor or any other constructor except the no-arg constructor.) A method named toString() that returns a string description of the air conditioner. If the air conditioner is on, the method returns the model, the current temperature setting and fan speed in words. Example: "The Iceberg is currently set to 68 degrees Fahrenheit with fan set to medium." If the air conditioner is off, the method returns the air conditioner model and the message that it is off. Example: "The Iceberg is currently turned off." In main, create two AirConditioner objects. For the first one, make its model the Friginator, the fan speed medium, and the temperature 69.5 degrees. For the second one, make it the Iceberg with the fan speed high and the temperature 72.0 degrees. Then simply display each object by invoking their toString method. Here are some hints: You may want to sketch a UML diagram for the AirConditioner class, but you do not have to turn that in. In main, use the AirConditioner's setters to change the values of the fields, since you cannot have a full constructor.  Create the  public speed constants in the AirConditioner class and then use them in main to set the fan speed of your AirConditioner object. You can access them like any static member. For example, to set a myAC's speed to low in main, you can say: myAC.setSpeed(AirConditioner.LOW);

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Java code

Lab 4 Problem Statement

Create a class named AirConditioner in its own file. (The main method should be in a different file.) The class should contain the following:

  • Three public constants named HIGHMEDIUM, and LOW with values of 1, 2, and 3 to denote the air conditioner fan speed.
  • A private int data field named speed that specifies the speed of the air conditioner fan. (The default is 1 for high.)
  • A private boolean data field named on that specifies whether the air conditioner is on or not. (The default is false.)
  • A private double data field named temperature that specifies the temperature setting of the air conditioner. (The default is 72.0.)
  • A private String data field named model that specifies the model name of the air conditioner. (The default is "Iceberg".)
  • The accessor and mutator methods (getters and setters) for all four data fields.
  • A no-arg constructor that creates a default air conditioner, with all the default settings. (Do not create a full constructor or any other constructor except the no-arg constructor.)
  • A method named toString() that returns a string description of the air conditioner.
    • If the air conditioner is on, the method returns the model, the current temperature setting and fan speed in words.
      Example: "The Iceberg is currently set to 68 degrees Fahrenheit with fan set to medium."
    • If the air conditioner is off, the method returns the air conditioner model and the message that it is off.
      Example: "The Iceberg is currently turned off."

In main, create two AirConditioner objects. For the first one, make its model the Friginator, the fan speed medium, and the temperature 69.5 degrees. For the second one, make it the Iceberg with the fan speed high and the temperature 72.0 degrees. Then simply display each object by invoking their toString method.

Here are some hints:

  • You may want to sketch a UML diagram for the AirConditioner class, but you do not have to turn that in.
  • In main, use the AirConditioner's setters to change the values of the fields, since you cannot have a full constructor. 
  • Create the  public speed constants in the AirConditioner class and then use them in main to set the fan speed of your AirConditioner object. You can access them like any static member. For example, to set a myAC's speed to low in main, you can say: myAC.setSpeed(AirConditioner.LOW);
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY