Ejemplo n.º 1
0
        private HeightData CreateHeightData(string keyAndValue)
        {
            var heightData = new HeightData();

            var keyInString = keyAndValue.Substring(keyAndValue.Length - 2, 2);

            heightData.HeightKey = Enum.Parse <HeightKey>(keyInString);
            if (heightData.HeightKey == HeightKey.cm || heightData.HeightKey == HeightKey.@in)
            {
                if (int.TryParse(keyAndValue.Substring(0, keyAndValue.Length - 2), out var value))
                {
                    heightData.HeightValue = value;
                }
            }
            return(heightData);
        }
Ejemplo n.º 2
0
        private bool IsHeightValid(HeightData heightData)
        {
            var heightValue = heightData.HeightValue;
            var heightKey   = heightData.HeightKey;

            if (heightKey == HeightKey.cm)
            {
                return(heightValue >= 150 && heightValue <= 193);
            }
            if (heightKey == HeightKey.@in)
            {
                return(heightValue >= 59 && heightValue <= 76);
            }
            else
            {
                return(false);
            }
        }