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); }
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); }
public DistanceConverter(ConverterBase from, ConverterBase to) { From = from; To = to; }