adventOfCode_2023/CSharp/AdventOfCode/DayTwo/CubeGameMaster.cs

26 lines
616 B
C#

namespace DayTwo;
public class CubeGameMaster
{
public string FilePath { get; set; }
public CubeGameMaster(string filePath)
{
FilePath = filePath;
}
public int ObtainSumOfValidGames()
{
using StreamReader reader = new StreamReader(FilePath);
var sumOfValidGames = 0;
while (!reader.EndOfStream)
{
// Read a line from the file
string line = reader.ReadLine() ?? "Something failed";
var game = new Game(line);
sumOfValidGames += game.GetIdIfValid();
}
return sumOfValidGames;
}
}