Пример #1
0
        public bool ReadFromFile(string[] files, InputTable input, OutputTable output)
        {
            if (files.Length != 2)
            {
                Console.WriteLine("Argument Error");
                return(false);
            }
            else
            {
                try
                {
                    using (var reader = new StreamReader(files[0]))
                    {
                        while (!reader.EndOfStream)
                        {
                            string row = reader.ReadLine();
                            input.Pass_Row(row, row_counter, output);
                            row_counter++;
                        }

                        return(true);
                    }
                }
                catch (IOException e)
                {
                    Console.WriteLine("File Error");
                    Console.WriteLine(e.Message);
                    return(false);
                }
            }
        }
Пример #2
0
        public void Pass_Row(string line, int row_number, OutputTable output)
        {
            string clean_row = Remove_Multiple_Spaces(line);

            string[] cells = clean_row.Split(' ');

            output.Add_Row_To_Table(cells, row_number, ref To_Compute);
        }
Пример #3
0
        public static void Run(string[] arguments)
        {
            Reader      reader       = new Reader();
            InputTable  input_table  = new InputTable();
            OutputTable output_table = new OutputTable();

            if (reader.ReadFromFile(arguments, input_table, output_table))
            {
                Compute_Table(input_table, output_table);
                Writer writer = new Writer();
                writer.Write_Output_Table(output_table, arguments[1]);
            }
        }
Пример #4
0
        public void Write_Output_Table(OutputTable output_table, string output_file)
        {
            using (var writer = new StreamWriter(output_file))
            {
                for (int i = 0; i < output_table.Table.Count; i++)
                {
                    for (int j = 0; j < output_table.Table[i].Length; j++)
                    {
                        writer.Write(output_table.Table[i][j]);
                        if (j != output_table.Table[i].Length - 1)
                        {
                            writer.Write(" ");
                        }
                    }

                    if (i != output_table.Table.Count - 1)
                    {
                        writer.WriteLine();
                    }
                }
            }
        }
Пример #5
0
        public static void Compute_Table(InputTable input, OutputTable output)
        {
            CellComputer computer = new CellComputer();

            output.Compute_Cells(input, computer);
        }