コード例 #1
0
        /// <summary>
        /// Translates from an internal height unit to a JavaScript height unit.
        /// </summary>
        /// <param name="heightUnit"></param>
        /// <returns></returns>
        private static string GetHeightUnit(HeightUnit heightUnit)
        {
            switch (heightUnit)
            {
            case HeightUnit.Feet:               return("f");

            case HeightUnit.Metres:             return("m");

            default:                            throw new NotImplementedException();
            }
        }
コード例 #2
0
        /// <summary>
        /// Returns a description of a height unit.
        /// </summary>
        /// <param name="heightUnit"></param>
        /// <returns></returns>
        public static string HeightUnit(HeightUnit heightUnit)
        {
            switch (heightUnit)
            {
            case Interface.HeightUnit.Feet:     return(Strings.Feet);

            case Interface.HeightUnit.Metres:   return(Strings.Metres);

            default:                            throw new NotImplementedException();
            }
        }
コード例 #3
0
            public double GetHeight(HeightUnit unit)
            {
                switch (unit)
                {
                case HeightUnit.Cm: return(Height);

                case HeightUnit.Meter: return(Height / 100);

                case HeightUnit.Feet: return(Height * 0.0328);

                default: throw new NotSupportedException($"Height unit {unit} not supported");
                }
            }
コード例 #4
0
ファイル: Passport.cs プロジェクト: chrisRagland/AoC2020
            public PassportHeight(string input)
            {
                if (input.EndsWith("cm"))
                {
                    Unit = HeightUnit.Centimeter;
                }
                else
                {
                    Unit = HeightUnit.Inch;
                }

                Height = Convert.ToInt32(input.Substring(0, input.Length - 2));
            }
コード例 #5
0
 public HeightWithUnit(double height, HeightUnit unit)
 {
     this.Num  = height.ToString();
     this.Unit = unit;
 }
コード例 #6
0
 public HeightWithUnit(string str, HeightUnit height)
 {
     this.Num  = str;
     this.Unit = height;
 }
コード例 #7
0
 public HeightContainer(double height, HeightUnit metric)
 {
     Height = height;
     Metric = metric;
 }