Air Conditioning Unit

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 13RQ
icon
Related questions
Question

JAVA CODE PLS

Air Conditioning Unit

by CodeChum Admin

Construct a class to represent an air conditioning (AC) unit containing the following attributes:

  • brand - name of manufacturers like Samsung, LG, Carrier, etc.
  • type - whether it is an inverter type or not
  • power - represents the status of the AC unit whether it is turned on or not
  • thermostat - levels go from 1 to 10
  • temperature - levels go from 16 to 30 (in .5 intervals)
  • It should have two constructors - one default and another that is overloaded
    • default constructor
      • sets all the numerical values to the least value as described above
      • sets power to off, and type to inverter
      • sets brand to "AC Brand"
      • prints "Default Constructor"
    • overloaded constructor
      • accepts brand and type as arguments
      • everything else is set to the same values as in the default constructor
      • prints "Overloaded Constructor"

 

It should contain the following methods:

  • power() - this is supposed to turn the AC on if it is off, and turn it off if it is on
  • thermostatUp() - increases thermostat by a value 1 (note that the thermostat has an upper limit)
  • thermostatDown() - decreases thermostat by a value 1 (note that the thermostat has a lower limit)
  • temperatureUp() - increases temperature by a value 0.5 (note that the temperature has an upper limit)
  • temperatureDown() - decreases temperature by a value 1 (note that the temperature has a lower limit)
  • display() - displays all the values of the member data (one member data per line) of AC following this format: <member_data>: <member_data_value>
  • getter methods for all the private members of AC 

Input

The first input is an integer which will create an instance of an AC unit depending on the constructor used. This is specified below: 1 - construct an AC unit object via the default constructor (no input needed) 2 - construct an AC unit object via the overloaded constructor (a String for the brand followed by 1 (inverter type) or 0 (non-inverter type)) Then a number m is encountered which represents the number of operations that have to be invoked. This is then followed by an integer representing what operator to execute. The operators are specified below: 3 - calls power() 4 - calls thermostatUp() 5 - calls thermostatDown() 6 - calls temperatureUp() 7 - calls temperatureDown() 8 - calls getBrand() 9 - calls getType() 10 - calls getPower() 11 - calls getThermostat() 12 - calls getTemperature() 13 - calls display()

1 4 14 3 4 13 14

Output

For each of the getter methods that gets called, the values they return must be printed. And it goes without saying that the constructors and display() method produce output.

Default·Constructor Brand:·AC·Brand Type:·true Power·status:·false· Thermostat:·1 Temperature:·16.0 Brand:·AC·Brand Type:·true Power·status:·true Thermostat:·2· Temperature:·16.0
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Computer cables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr