Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author Rifqi Mukti W
- * @version 29/09/2017
- */
- public class Heater
- {
- // instance variables - replace the example below with your own
- private double temperature;
- private double min;
- private double max;
- private double increment;
- /**
- * Constructor for objects of class Heater
- */
- public Heater(double temperatureMin, double temperatureMax)
- {
- temperature = 15.0;
- min = temperatureMin;
- max = temperatureMax;
- increment = 5.0;
- }
- public void warmer()
- {
- if (temperature + increment > max)
- {
- System.out.println("The value is invalid.");
- }
- else
- {
- temperature = temperature + 5.0;
- }
- }
- public void cooler()
- {
- if (temperature + increment < min)
- {
- System.out.println("The value is invalid.");
- }
- else
- {
- temperature = temperature - 5.0;
- }
- }
- public void setIncrement(double input)
- {
- if (input < 0)
- System.out.println("Wrong input!.");
- else increment = input;
- }
- public double getTemperature()
- {
- return temperature;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement