コード例 #1
0
        static ConverterBase GetConverter(string msg)
        {
            ConverterBase converter = null;

            do
            {
                Console.Write(msg + " => ");
                var unit = Console.ReadLine();
                converter = ConverterFactory.GetInstance(unit);
            } while (converter == null);
            return(converter);
        }
コード例 #2
0
        static double GetDistance(ConverterBase from)
        {
            double?value = null;

            do
            {
                Console.Write($"변환하려는 거리(단위:{from.UnitName})를 입력하세요 => ");
                var    line = Console.ReadLine();
                double temp;
                value = double.TryParse(line, out temp) ? (double?)temp : null;
            } while (value == null);
            return(value.Value);
        }
コード例 #3
0
 public DistanceConverter(ConverterBase from, ConverterBase to)
 {
     From = from;
     To   = to;
 }