From ec89a212a946968e36a8ff659f24c0181deaf0af Mon Sep 17 00:00:00 2001 From: Janco Kock Date: Sun, 1 Nov 2015 21:53:49 +0100 Subject: [PATCH] Added some more calculation functions. --- .../ErgometerApplication/ErgometerTest.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/ErgometerIPR/ErgometerApplication/ErgometerTest.cs b/ErgometerIPR/ErgometerApplication/ErgometerTest.cs index 246f331..6fc1996 100644 --- a/ErgometerIPR/ErgometerApplication/ErgometerTest.cs +++ b/ErgometerIPR/ErgometerApplication/ErgometerTest.cs @@ -194,6 +194,44 @@ namespace ErgometerApplication return VOABS * 1000 / weight; } + public double CalculateMET() + { + return CalculateVOMax() / 3.5; + } + + public double CalculatePopulationAverage() + { + if(gender == 'M') + return 51.86 - 0.28 * age; + return 41.435 - 0.23 * age; + } + + public string CalculateRating() + { + var dev = (gender == 'M') ? 6 : 5.5; + var Zscore = (CalculateVOMax() - CalculatePopulationAverage()) / dev; + if (Zscore >= 1) + { + return "Geweldig"; + } + else if (Zscore < 1 && Zscore >= 0.5) + { + return "Goed"; + } + else if (Zscore < 0.5 && Zscore >= -0.5) + { + return "Gemiddeld"; + } + else if (Zscore < -0.5 && Zscore >= -1) + { + return "Redelijk"; + } + else if (Zscore < -1) + { + return "Slecht"; + } + return "Undefined"; + } // HELPER FUNCTIONS //