ErgometerTest.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ErgometerApplication
  7. {
  8. class ErgometerTest
  9. {
  10. private int weight;
  11. private int length;
  12. private int age;
  13. private enum state {WARMUP, WORKLOAD1, WORKLOAD2, WORKLOAD3, WORKLOAD4, COOLINGDOWN};
  14. private state currentstate;
  15. private int stateStarted;
  16. public ErgometerTest(int weight, int length , int age)
  17. {
  18. this.weight = weight;
  19. this.length = length;
  20. this.age = age;
  21. this.currentstate = state.WARMUP;
  22. stateStarted = 0;
  23. }
  24. private double CalculateMaximumHeartRate()
  25. {
  26. return 208 - (0.7 * age);
  27. }
  28. public void timerTick()
  29. {
  30. if(currentstate == state.WARMUP)
  31. {
  32. if (MainClient.Metingen.Last().Seconds > 30)
  33. {
  34. List<ErgometerLibrary.Meting> last10 = MainClient.Metingen.GetRange(MainClient.Metingen.Count - 10, 10);
  35. int max = FindMaxValue(MainClient.Metingen, x => x.HeartBeat);
  36. int min = FindMaxValue(MainClient.Metingen, x => x.HeartBeat);
  37. };
  38. }
  39. }
  40. public int FindMaxValue<T>(List<T> list, Converter<T, int> projection)
  41. {
  42. if (list.Count == 0)
  43. {
  44. throw new InvalidOperationException("Empty list");
  45. }
  46. int maxValue = int.MinValue;
  47. foreach (T item in list)
  48. {
  49. int value = projection(item);
  50. if (value > maxValue)
  51. {
  52. maxValue = value;
  53. }
  54. }
  55. return maxValue;
  56. }
  57. public int FindMinValue<T>(List<T> list, Converter<T, int> projection)
  58. {
  59. if (list.Count == 0)
  60. {
  61. throw new InvalidOperationException("Empty list");
  62. }
  63. int minValue = int.MaxValue;
  64. foreach (T item in list)
  65. {
  66. int value = projection(item);
  67. if (value < minValue)
  68. {
  69. minValue = value;
  70. }
  71. }
  72. return minValue;
  73. }
  74. }
  75. }