Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Exercise 2.93 & 2.94
- *
- * The Heater class represents a "blueprint" for a heater object
- * in which you can adjust its temperature and adjust the
- * increment in which you change the temperature.
- *
- * @author (Jonah Broyer)
- * @version (1/18/2020)
- */
- public class Heater
- {
- // the temperature of the heater
- private double temperature;
- private double min;
- private double max;
- private double increment;
- /**
- * Create a new heater
- */
- public Heater(double tempMinimum, double tempMaximum)
- {
- temperature = 15.0;
- min = tempMinimum;
- max = tempMaximum;
- increment = 5.0;
- }
- /**
- * Increase the temperature of the heater.
- */
- public void warmer()
- {
- if(temperature <= max) {
- temperature = temperature + increment;
- }
- }
- /**
- * Decrease the temperature of the heater.
- */
- public void cooler()
- {
- if(temperature >= min) {
- temperature = temperature - increment;
- }
- }
- /**
- * Return what the heaters temperature is.
- */
- public double getTemperature()
- {
- return temperature;
- }
- /**
- * Set how much to increment the heater by.
- */
- public void setIncrement(double newIncrement)
- {
- if(newIncrement >= 0.0) {
- increment = newIncrement;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement