adventOfCode_2023/CSharp/AdventOfCode/DayOne/CalibratorReader.cs

27 lines
656 B
C#

using AdventOfCode;
namespace DayOne;
public class CalibratorReader
{
public string FilePath { get; set; }
public CalibratorReader(string filePath)
{
FilePath = filePath;
}
public int ObtainCalibrationValue()
{
using StreamReader reader = new StreamReader(FilePath);
var calibrationResult = 0;
while (!reader.EndOfStream)
{
// Read a line from the file
string line = reader.ReadLine() ?? "Something failed";
calibrationResult = calibrationResult + CalibratorEvaluator.ObtainLineCalibration(line);
}
return calibrationResult;
}
}