public List<LogicRecord> GetLogicRecords(string fileName)
        {
            List<string> allLinesInFile = File.ReadAllLines(fileName).ToList();
            List<LogicRecord> _logicRecords = new List<LogicRecord>();

            foreach (string line in allLinesInFile)
            {
                string[] splitColumns = line.Split(' ');
                LogicRecord logicRecord = new LogicRecord();
                bool success = Enum.TryParse(splitColumns[0], out logicRecord._operator);
                if (success)
                {
                    int lengthOfInput = splitColumns.Length - 1;
                    for (int i = 1; i < lengthOfInput; i++)
                    {
                        int input = int.Parse(splitColumns[i]);
                        logicRecord._inputs.Add(input);
                    }

                    logicRecord._output = int.Parse(splitColumns[splitColumns.Length - 1]);
                    _logicRecords.Add(logicRecord);
                }
            }

            return _logicRecords;
        }
Exemplo n.º 2
0
        public List <LogicRecord> GetLogicRecords(string fileName)
        {
            List <string>      allLinesInFile = File.ReadAllLines(fileName).ToList();
            List <LogicRecord> _logicRecords  = new List <LogicRecord>();

            foreach (string line in allLinesInFile)
            {
                string[]    splitColumns = line.Split(' ');
                LogicRecord logicRecord  = new LogicRecord();
                bool        success      = Enum.TryParse(splitColumns[0], out logicRecord._operator);
                if (success)
                {
                    int lengthOfInput = splitColumns.Length - 1;
                    for (int i = 1; i < lengthOfInput; i++)
                    {
                        int input = int.Parse(splitColumns[i]);
                        logicRecord._inputs.Add(input);
                    }

                    logicRecord._output = int.Parse(splitColumns[splitColumns.Length - 1]);
                    _logicRecords.Add(logicRecord);
                }
            }

            return(_logicRecords);
        }