Grootheid.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import java.util.ArrayList;
  2. public class Grootheid
  3. {
  4. // instance variables - replace the example below with your own
  5. public double avg;
  6. public double max;
  7. public double min;
  8. public double current;
  9. //constructor
  10. public Grootheid(){
  11. avg = 0;
  12. max = 0;
  13. min = 0;
  14. current = 0;
  15. }
  16. //getters & setters
  17. public double getCurrent() {
  18. return current;
  19. }
  20. public void setCurrent(double current) {
  21. this.current = current;
  22. }
  23. public double getMax() {
  24. return max;
  25. }
  26. public void setMax(double max) {
  27. this.max= max;
  28. }
  29. public double getMin() {
  30. return min;
  31. }
  32. public void setMin(double min) {
  33. this.min = min;
  34. }
  35. public double getAvg() {
  36. return avg;
  37. }
  38. public void setAvg(double avg) {
  39. this.avg = avg;
  40. }
  41. //Methods
  42. public void calculateMaxMinAvg(ArrayList<Double> laatste24uur){
  43. double tempMax = 0;
  44. double tempAvg = 0;
  45. double tempMin = laatste24uur.get(0);
  46. for(double ms : laatste24uur){
  47. if(ms > tempMax){
  48. tempMax = ms;
  49. }
  50. if(ms < tempMin){
  51. tempMin = ms;
  52. }
  53. tempAvg += ms;
  54. }
  55. tempAvg /= laatste24uur.size();
  56. setMax(tempMax);
  57. setMin(tempMin);
  58. setAvg(tempAvg);
  59. }
  60. public void updateRecent(Measurement measurement1){
  61. }
  62. public void update24Hour(ArrayList<Measurement> measurement2){
  63. }
  64. public void display(){
  65. GUIboard.writeUpperDigits(getCurrent());
  66. GUIboard.writeLeftDigits(getMax());
  67. GUIboard.writeRightDigits(getMin());
  68. }
  69. public void displayGraph()
  70. {
  71. }
  72. }