added constructor params

master
cyberdick 2022-12-03 17:06:05 +05:30
parent 754cf5f4b9
commit 74fa2da997
2 changed files with 13 additions and 2 deletions

View File

@ -58,9 +58,10 @@ internal static class Program
string instanceToCreate = "AOC2022.Puzzles.Day" + day; string instanceToCreate = "AOC2022.Puzzles.Day" + day;
Type? typeName = Type.GetType(typeName: instanceToCreate); Type? typeName = Type.GetType(typeName: instanceToCreate);
var linesInFile = File.ReadAllLines($"Inputs/{day}.txt");
if (typeName != null) if (typeName != null)
{ {
if (Activator.CreateInstance(typeName) is IPuzzle puzzle) if (Activator.CreateInstance(typeName, new object[] { linesInFile }) is IPuzzle puzzle)
{ {
puzzle.FirstPuzzle(); puzzle.FirstPuzzle();
puzzle.SecondPuzzle(); puzzle.SecondPuzzle();

View File

@ -8,9 +8,19 @@ namespace AOC2022.Puzzles;
internal class Day1 : IPuzzle internal class Day1 : IPuzzle
{ {
private readonly string[] linesFromFile;
public Day1(string[] linesFromFile)
{
this.linesFromFile = linesFromFile;
}
public void FirstPuzzle() public void FirstPuzzle()
{ {
throw new NotImplementedException(); foreach (var line in linesFromFile)
{
Console.WriteLine(line);
}
} }
public void SecondPuzzle() public void SecondPuzzle()