/// <summary> /// Set lblResult text and color by Body Mass Index /// </summary> /// <param name="pNuBMI"></param> /// <param name="pBodyMassIndex"></param> private void SetLblResult(float pNuBMI, BodyMassIndex pBodyMassIndex) { this.view.lblResult.Text = $"Your BMI is {pNuBMI}.\nYou are {pBodyMassIndex}."; switch (pBodyMassIndex) { case (BodyMassIndex.Underweight): this.view.lblResult.ForeColor = Color.Blue; break; case (BodyMassIndex.Normal): this.view.lblResult.ForeColor = Color.Green; break; case (BodyMassIndex.Overweigth): this.view.lblResult.ForeColor = Color.Gold; break; case (BodyMassIndex.Obese): this.view.lblResult.ForeColor = Color.Orange; break; default: // BodyMassIndex.ExtremellyObese this.view.lblResult.ForeColor = Color.Red; break; } }
public override GenRange Calculate(BodyMassIndex bmi, PersonAge age) { Range <Rating> rangeForSpeed; if (bmi.BMI > 22.8) { rangeForSpeed = MinRange; } else if (bmi.BMI < 21.2) { rangeForSpeed = MaxRange; } else { rangeForSpeed = MediumRange; } // take player age into account if (age > PersonAge.FromYears(30)) { rangeForSpeed = new Range <Rating>(rangeForSpeed.Lower * 0.82, rangeForSpeed.Upper * 0.88); } else if (age < PersonAge.FromYears(23)) { rangeForSpeed = new Range <Rating>(rangeForSpeed.Lower * 1.052, rangeForSpeed.Upper * 1.055); } return(new GenRange(FeatureType.Acceleration, rangeForSpeed)); }
public void New_PassWeightOfZeroKilograms_ShouldThrowBusinessRuleValidationException() { Assert.ThrowsException <BusinessRuleValidationException>(() => { var bmi = new BodyMassIndex(new Length(1, LengthUnit.Meter), new Mass()); }); }
/// <summary> /// Validates this MeasurementInformation /// </summary> /// <param name="path">The path to this object as a string</param> /// <param name="messages">the validation messages to date, these may be added to within this method</param> public void Validate(string path, List <ValidationMessage> messages) { var vb = new ValidationBuilder(path, messages); if (HeadCircumference == null && BodyHeight == null && BodyMassIndex == null && BodyWeight == null) { vb.AddValidationMessage("MeasurementInformation", null, "Please provide an entry for MeasurementInformation"); } if (HeadCircumference != null) { HeadCircumference.Validate(path, messages); } if (BodyHeight != null) { BodyHeight.Validate(path, messages); } if (BodyMassIndex != null) { BodyMassIndex.Validate(path, messages); } if (BodyWeight != null) { BodyWeight.Validate(path, messages); } }
public void New_PassHeightOfZeroCentimeters_ShouldThrowBusinessRuleValidationException() { Assert.ThrowsException <BusinessRuleValidationException>(() => { var bmi = new BodyMassIndex(new Length(), new Mass(50, MassUnit.Kilogram)); }); }
public override GenRange Calculate(BodyMassIndex bmi, PersonAge age) { Range <Rating> rangeForPower; if (bmi.BMI > 23 && bmi.Height.Centimeters >= 185) { rangeForPower = MaxRange; } else if (bmi.BMI < 22) { rangeForPower = MinRange; } else { rangeForPower = MediumRange; } // take player's age into account if (age > PersonAge.FromYears(25)) { rangeForPower = new Range <Rating>(rangeForPower.Lower * 1.05, rangeForPower.Upper * 1.05); } else if (age < PersonAge.FromYears(20)) { rangeForPower = new Range <Rating>(rangeForPower.Lower * 0.8, rangeForPower.Upper * 0.9); } return(new GenRange(FeatureType.Power, rangeForPower)); }
private void btnCalculate_Click(object sender, EventArgs e) { BodyMassIndex bmi = new BodyMassIndex((double)numWeight.Value, (double)numHeight.Value); bmi.CalculateBMI(); lblBMI.Text = bmi.getBMI().ToString(); }
public void BodyMassIndex_Bmi_SampleTest() { Assert.AreEqual("Normal", BodyMassIndex.Bmi(80, 1.80)); Assert.AreEqual("Normal", BodyMassIndex.Bmi(80, 1.80)); Assert.AreEqual("Overweight", BodyMassIndex.Bmi(90, 1.80)); Assert.AreEqual("Obese", BodyMassIndex.Bmi(110, 1.80)); }
public void New_PassValidValues_ShouldReturnNewBmiWithUnderweightRange() { BodyMassIndex bmi = new BodyMassIndex(new Length(2, LengthUnit.Meter), new Mass(60, MassUnit.Kilogram)); Assert.IsNotNull(bmi); Assert.IsNotNull(bmi.BmiRange); Assert.AreEqual(BodyMassIndex.Underweight, bmi.BmiRange); Assert.AreEqual(BmiType.Underweight, bmi.BmiType); }
public void mapToTableAttribute() { this.bmi = new BodyMassIndex(); this.bmi.setDateBmi(DateTime.Now.Date); this.bmi.setWeight(FormUtils.convertDouble(txtWeight.Text)); this.bmi.setHeight(FormUtils.convertDouble(txtHeight.Text)); this.bmi.setResult(FormUtils.convertDouble(labResult.Text)); this.bmi.setEvaluation(bmi.evaluate()); }
public Dictionary <String, Object> singleParam(BodyMassIndex bmi) { Dictionary <String, Object> d = new Dictionary <string, object>() { { "@DateBmi", bmi.getDateBmi() } }; return(d); }
public PhysicalFeatureSet Generate(PlayerPosition position, BodyMassIndex bmi, Country country, PersonAge playerAge) { PlayerPositionGenerationRangeDefinition playerPositionGenRange = PlayerPositionGenerationRangeDefinition.GetFromPosition(position); ReadOnlyCollection <GenRange> positionGenRanges = playerPositionGenRange.GetGenerationRangeDefinitions(); ReadOnlyCollection <GenRange> bmiGenRanges = BodyMassIndexGenerationRangeDefinition.Generate(bmi, playerAge); // plages de génération différentes en fonction de // - la position du joueur // - du BMI // - du pays (à voir plus tard) // - [TODO] de l'âge du joueur PhysicalFeatureSet set = PhysicalFeatureSet.CreateFeatureSet(position.PositionCategory); Parallel.ForEach(set.PhysicalFeatures, feature => { // foreach (PhysicalFeature feature in set.PhysicalFeatures) //{ Rating rating; GenRange genRangeFromPosition = positionGenRanges.FirstOrDefault(c => c.FeatureType == feature.FeatureType); GenRange genRangeFromBmi = bmiGenRanges.FirstOrDefault(c => c.FeatureType == feature.FeatureType); if (genRangeFromBmi != null && genRangeFromPosition != null) { Range <Rating> range = Range <Rating> .MergeRanges(new Range <Rating>[] { genRangeFromBmi.RatingRange, genRangeFromPosition.RatingRange }); rating = _randomiser.Randomise(range); } else { if (genRangeFromPosition != null) { rating = _randomiser.Randomise(genRangeFromPosition.RatingRange); } else { //if (feature.FeatureType == FeatureType.Morale) //{ // rating = _randomiser.Randomise(); //} //else //{ rating = _randomiser.Randomise(_youngPlayerFeatureRatingRange); //} } } feature.ChangeRating(rating); //} }); return(set); }
/// <summary> /// Validates this PhysicalMeasurementBodyMassIndex item /// </summary> /// <param name="path">The path to this object as a string</param> /// <param name="messages">the validation messages to date, these may be added to within this method</param> public void Validate(string path, List <ValidationMessage> messages) { var vb = new ValidationBuilder(path, messages); if (vb.ArgumentRequiredCheck("BodyMassIndex", BodyMassIndex)) { BodyMassIndex.Validate(vb.Path + "BodyMassIndex", vb.Messages); } if (BodyMassIndexReferenceRangeDetails != null) { for (var x = 0; x < BodyMassIndexReferenceRangeDetails.Count; x++) { BodyMassIndexReferenceRangeDetails[x].Validate(vb.Path + string.Format("BodyMassIndexReferenceRangeDetails[{0}]", x), vb.Messages); } } if (Method != null) { Method.Validate(vb.Path + "Method", vb.Messages); } if (InformationProvider != null) { if (InformationProvider is Device) { var device = InformationProvider as Device; device.Validate(vb.Path + "Device", vb.Messages); } // Both types are of type Participation so use the Participant to determin the type if (InformationProvider is Participation) { var informationProviderHealthcareProvider = InformationProvider as IParticipationInformationProviderHealthcareProvider; if (informationProviderHealthcareProvider.Participant != null) { informationProviderHealthcareProvider.Validate(vb.Path + "IParticipationInformationProviderHealthcareProvider", vb.Messages); } var informationProviderNonHealthcareProvider = InformationProvider as IParticipationInformationProviderNonHealthcareProvider; if (informationProviderNonHealthcareProvider.Participant != null) { informationProviderNonHealthcareProvider.Validate(vb.Path + "IParticipationInformationProviderNonHealthcareProvider", vb.Messages); } } } vb.ArgumentRequiredCheck("BodyMassIndexDateTime", BodyMassIndexDateTime); if (vb.ArgumentRequiredCheck("BodyMassIndexInstanceIdentifier", BodyMassIndexInstanceIdentifier)) { BodyMassIndexInstanceIdentifier.Validate(vb.Path + "BodyMassIndexInstanceIdentifier", vb.Messages); } }
private void BtnCalculate_Click(object sender, EventArgs e) { if (this.ValidateControls()) { float nuBMI = this.CalculateBMI(Convert.ToSingle(this.view.txtNuMass.Text), Convert.ToSingle(this.view.txtNuHeight.Text.Replace('.', ','))); BodyMassIndex bodyMassIndex = this.GetBodyMassIndex(nuBMI); this.SetLblResult(nuBMI, bodyMassIndex); } }
public static ReadOnlyCollection <GenRange> Generate(BodyMassIndex bmi, PersonAge age) { var list = new List <GenRange>(); list.Add(new BmiRangeForPowerCalculator().Calculate(bmi, age)); list.Add(new BmiRangeForHeaderCalculator().Calculate(bmi, age)); list.Add(new BmiRangeForSpeedCalculator().Calculate(bmi, age)); list.Add(new BmiRangeForAccelerationCalculator().Calculate(bmi, age)); return(list.AsReadOnly()); }
public void BodyMassIndex_Bmi_RandomTest() { for (int i = 0; i < 100; ++i) { double weight = rnd.NextDouble() * 250 + 50; double height = rnd.NextDouble() * 2.5 + 0.5; string expected = Solution(weight, height); string actual = BodyMassIndex.Bmi(weight, height); Assert.AreEqual(expected, actual); } }
public Dictionary <String, Object> parametres(BodyMassIndex bmi) { Dictionary <String, object> d = new Dictionary <String, Object>() { { "@Date_Bmi", DateTime.Now.Date }, { "@Weight", bmi.getWeight() }, { "@Height", bmi.getHeight() }, { "@Value", bmi.getResult() }, { "@Evaluation", bmi.getEvaluation() }, }; return(d); }
public string Bmi() { var bmi = new BodyMassIndex(this.weight, this.height); if (bmi.UnderWeight()) { return("You are under weight. You should see your doctor."); } else if (bmi.OverWeight()) { return("You are over weight. You should see your doctor."); } return("You are in the correct weight range."); }
public void Classification_GivenDemographicsAndBmiInfo_ReturnsCorrectBmiClassification( double bmi, Race race, BodyMassIndex expectecBodyMassIndex) { var bodyComposition = BodyCompositionBuilder.Initialize() .SetHeight(LengthConversion.CentimetersToInches(100)) .SetWeight(MassConversion.KilogramsToLbs(bmi)) .BuildWithoutModelValidation(); var patient = PatientBuilder.Initialize() .SetRace(race) .BuildWithoutModelValidation(); var result = new BodyMassIndexClassification(new BodyCompositionClassificationParameters(bodyComposition, patient)) .Classification; Assert.Equal(expectecBodyMassIndex, result); }
public override GenRange Calculate(BodyMassIndex bmi, PersonAge age) { Range <Rating> rangeForHeader; if (bmi.Height >= _minimuHeightForMaxRange) { rangeForHeader = MaxRange; } else if (bmi.Height < _minimuHeightForMinRange) { rangeForHeader = MinRange; } else { rangeForHeader = MediumRange; } return(new GenRange(FeatureType.Header, rangeForHeader)); }
/// <summary> /// Validates this MeasurementEntry /// </summary> /// <param name="path">The path to this object as a string</param> /// <param name="messages">the validation messages to date, these may be added to within this method</param> public void Validate(string path, List <ValidationMessage> messages) { var vb = new ValidationBuilder(path, messages); if (DocumentLink != null) { if (DocumentLink != null) { DocumentLink.Validate(path, messages); } } if (BodyHeightMeasure != null) { BodyHeightMeasure.Validate(path, messages); } if (BodyWeightMeasure != null) { BodyWeightMeasure.Validate(path, messages); } if (HeadCircumferenceMeasure != null) { HeadCircumferenceMeasure.Validate(path, messages); } if (BodyMassIndex != null) { BodyMassIndex.Validate(path, messages); } //if (BodyHeightMeasure == null && BodyWeightMeasure == null && HeadCircumferenceMeasure == null && BodyMassIndex == null) //{ // vb.AddValidationMessage("Measurement component", null, "Please provide one of the following BodyHeightMeasure or BodyWeightMeasure or HeadCircumferenceMeasure or BodyMassIndex"); //} if (BodyMassIndex != null) { BodyMassIndex.Validate(path, messages); } vb.ArgumentRequiredCheck("ObservationDate", ObservationDate); }
private Player ( PersonId id, PersonName name, Gender gender, BirthInfo birthInfo, Foot favouriteFoot, BodyMassIndex bmi, Percentile percentile, PhysicalFeatureSet physicalFeatureSet, PlayerPosition playerPosition, params Country[] nationalities ) : base(id, name, gender, birthInfo, nationalities) { FavouriteFoot = favouriteFoot; Bmi = bmi; Percentile = percentile; PhysicalFeatureSet = physicalFeatureSet; PlayerPosition = playerPosition; }
public async Task <Player> GenerateAsync(Gender?playerGender = null, Country[] countries = null, PlayerPosition playerPosition = null) { if (playerGender == null) { playerGender = _genderGenerator.Generate(); } if (countries == null) { countries = _countriesGenerator.Generate().Value; } PersonName playerName = await _nameGenerator.GenerateAsync( playerGender.Value, countries.FirstOrDefault()); Date dob = _dobGenerator.Generate(); PersonAge playerAge = PersonAge.FromDate(dob, _game.CurrentDate); Location birthLocation = await _birthLocationGenerator.GenerateAsync(countries.FirstOrDefault()); Foot playerFoot = _favouriteFootGenerator.Generate(); Percentile percentile = _percentileGenerator.Generate(); BodyMassIndex bmi = _bmiGenerator.Generate(countries.FirstOrDefault(), playerGender.Value, percentile, dob); PlayerPosition position = _playerPositionGenerator.Generate(); PhysicalFeatureSet playerFeatureSet = _physicalFeatureSetGenerator.Generate(position, bmi, countries.FirstOrDefault(), playerAge); // first name & last name => according to the player's country return(new PlayerBuilder() .WithName(playerName) .WithGender(playerGender.Value) .WithBirthInfo(new BirthInfo(dob, birthLocation)) .WithFoot(playerFoot) .WithPercentile(percentile) .WithBodyMassIndex(bmi) .WithPlayerPosition(position) .WithFeatureSet(playerFeatureSet) .WithCountries(countries) .Build()); }
public static Player CreatePlayer ( PersonName name, Gender gender, BirthInfo birthInfo, Foot favouriteFoot, BodyMassIndex bmi, Percentile percentile, PhysicalFeatureSet physicalFeatureSet, PlayerPosition playerPosition, params Country[] nationalities ) => new Player ( PersonId.CreateNew(), name, gender, birthInfo, favouriteFoot, bmi, percentile, physicalFeatureSet, playerPosition, nationalities );
public void ChangeRating(BodyMassIndex bmi, Rating newRating) { _bmi = bmi; ChangeRating(newRating); }
public void New_PassValidValues_ShouldReturnNewBmi() { BodyMassIndex bmi = new BodyMassIndex(new Length(1.5, LengthUnit.Meter), new Mass(50, MassUnit.Kilogram)); Assert.IsNotNull(bmi); }
public BodyFatPercentage(decimal weight, int height, int age, string gender) { BMI = new BodyMassIndex(weight, height); this.age = age; this.gender = gender == "m" ? 1 : 0; }
public PlayerBuilder WithBodyMassIndex(BodyMassIndex bmi) { _bmi = bmi; return(this); }
public string Bmi() { var bmi = new BodyMassIndex(this.weight, this.height); if (bmi.UnderWeight()) { return "You are under weight. You should see your doctor."; } else if (bmi.OverWeight()) { return "You are over weight. You should see your doctor."; } return "You are in the correct weight range."; }
public TopSpeedFeature(BodyMassIndex bmi = null, Rating rating = null) : base(FeatureType.TopSpeed, rating) { _bmi = bmi; }
public bool delete(BodyMassIndex bmi) { bool index = createSQLDelete(FormUtils.loadConfigs("TABLE_BMI"), singleParam(bmi)); return(index); }