Advertisement
nawamkihafahd

Untitled

Sep 28th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public class Heater
  2. {
  3. // instance variables - replace the example below with your own
  4. private double temperature;
  5. private double max, min, increment;
  6. public Heater(int maxinp, int mininp)
  7. {
  8. // initialise instance variables
  9. temperature = 15;
  10. increment = 5;
  11. max = maxinp;
  12. min = mininp;
  13. }
  14. public void warmer()
  15. {
  16. temperature = temperature + increment;
  17. if(temperature > max)
  18. {
  19. temperature = max;
  20. }
  21. }
  22. public void cooler()
  23. {
  24. temperature = temperature - increment;
  25. if(temperature < min)
  26. {
  27. temperature = min;
  28. }
  29. }
  30. public void setIncrement(double setinc)
  31. {
  32. if(setinc > 0)
  33. {
  34. increment = setinc;
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement