コード例 #1
0
 public static void ReadNumberNotZero(ref double x, LogFileWriter logWriter)
 {
     if (x == 0)
     {
         Console.WriteLine("Incorrect data: leading coefficient = 0! Try again:");
         logWriter.WriteIncorrectDataToLog("leading coefficient = " + x.ToString());
         x = DoubleNumberInputter.ReadNumberFromConsole(logWriter);
     }
 }
コード例 #2
0
        public static double ReadNumberFromConsole(LogFileWriter logWriter)
        {
            string stringForParse;
            double numberAfterParse;

            Console.WriteLine("Input double coefficient:");
            stringForParse = Console.ReadLine();
            while (!double.TryParse(stringForParse.Replace(',', '.'), out numberAfterParse))
            {
                Console.WriteLine("Incorrect coefficient! Try again:");
                logWriter.WriteIncorrectDataToLog(stringForParse);
                stringForParse = Console.ReadLine();
            }
            return(numberAfterParse);
        }