Question
Create a new project, heater, within BlueJ. Create a class Heater as described below. (1) The class contains four fields: temperature , min , max
Create a new project, heater, within BlueJ. Create a class Heater as described below. (1)
The class contains four fields: temperature, min, max, and increment whose types are double. (2)
Define a constructor that takes two input parameters of the appropriate types. The values of min and max should be set to the corresponding parameters. The value of increment should be set to 5.0. The value of temperature should be set to 15.0. (3)
Define the mutators warmer and cooler, whose e ect is to increase or decrease the value of tem- perature. Use increment to set the temperature. Then modify the warmer method so that it will not allow the temperature to be set to a value greater than max. Similarly, modify cooler so that it will not allow temperature to be set to a value less than min. (3 + 3)
Define an accessor method getTemperature to return the value of temperature. (2)
Define a method setIncrement that takes a single parameter of the appropriate type and uses it to set the value of increment. Add a check to this method to prevent a negative value from being assigned to increment. (3)
Define a method printCurrentTemperature that prints out the following statement: Current heater temperature is set to #.
such that # is the value of temperature. (3)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started