예제 #1
0
        private static void LoadFromFile(string filename, EquationNormalizer normalizer)
        {
            string       equation;
            string       output = String.Empty;
            StreamReader file;

            try
            {
                file = new StreamReader(filename);
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Cannot find file {0}", filename);
                return;
            }


            while ((equation = file.ReadLine()) != null)
            {
                if (equation.Length > 0)
                {
                    output += equation + "   ->   " + normalizer.Normalize(equation) + "\n";
                }
            }

            string outputFileName = filename + ".out";

            File.WriteAllText(outputFileName, output);
            Console.WriteLine("File {0} with output has been generated", outputFileName);
        }
예제 #2
0
 private static void StartInteractive(EquationNormalizer normalizer)
 {
     while (true)
     {
         Console.WriteLine("Please enter an equation below:");
         Console.Write("> ");
         string equation = Console.ReadLine();
         Console.WriteLine("\n" + normalizer.Normalize(equation) + "\n");
     }
 }