Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Heater
- {
- // instance variables - replace the example below with your own
- private double temperature;
- private double max, min, increment;
- public Heater(int maxinp, int mininp)
- {
- // initialise instance variables
- temperature = 15;
- increment = 5;
- max = maxinp;
- min = mininp;
- }
- public void warmer()
- {
- temperature = temperature + increment;
- if(temperature > max)
- {
- temperature = max;
- }
- }
- public void cooler()
- {
- temperature = temperature - increment;
- if(temperature < min)
- {
- temperature = min;
- }
- }
- public void setIncrement(double setinc)
- {
- if(setinc > 0)
- {
- increment = setinc;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement