public void Convert() { Logger.Log("Program is starting..."); Logger.Log("Enter the number to convert:"); DecimalNumber = Reader.ReadInteger(); Logger.Log("Enter the base type (Ex: 2,8):"); BaseType baseType = (BaseType)Reader.ReadInteger(); string result; switch (baseType) { case BaseType.Binary: result = System.Convert.ToString(DecimalNumber, 2); break; case BaseType.Octal: result = System.Convert.ToString(DecimalNumber, 8); break; case BaseType.Hexadecimal: result = DecimalNumber.ToString("X"); break; default: result = "No base found!"; break; } Logger.Log(result); Logger.Log("Program is ending.."); }
public void Convert() { Logger.Log("Program is starting..."); Writer.Log("Enter the number to convert:"); DecimalNumber = Reader.ReadInteger(); if (string.IsNullOrEmpty(DecimalNumber.ToString())) { Writer.Log("You entered an invalid integer value."); } Logger.Log($"The number to convert is: {DecimalNumber}"); Writer.Log("Enter the base type (Ex: 2,8,16):"); Base = (BaseType)Reader.ReadInteger(); Logger.Log($"The selected base type is: {Base.ToString() }"); var type = ConverterFactory.Create(Base, DecimalNumber); Logger.Log($"using the converter: {type.GetType() }"); Result = type.Convert(); Writer.Log(Result); Logger.Log($"The result is: {Result} "); Logger.Log("Program is ending.."); }
public override string Convert() { return($"The result is: {DecimalNumber.ToString("X")}"); }