Added relative data path to TSolverEngine for testing

This commit is contained in:
Stefan Müller 2023-12-04 16:29:32 +01:00 committed by Stefan Müller
parent afa393a168
commit 05e4944521
2 changed files with 10 additions and 2 deletions

View File

@ -51,7 +51,7 @@ begin
WriteLn('### Advent of Code 2023 ###');
TTrebuchet.Run;
TCubeConundrum.Run;
engine := TSolverEngine.Create;
engine := TSolverEngine.Create('data');
engine.RunAndFree(TGearRatios.Create);
engine.Free;
end;

View File

@ -62,7 +62,10 @@ type
{ TSolverEngine }
TSolverEngine = class
private
FRelativeDataPath: string;
public
constructor Create(const ARelativeDataPath: string);
procedure ProcessData(const ASolver: ISolver);
procedure Run(const ASolver: ISolver);
procedure RunAndFree(const ASolver: ISolver);
@ -90,6 +93,11 @@ end;
{ TSolverEngine }
constructor TSolverEngine.Create(const ARelativeDataPath: string);
begin
FRelativeDataPath := ARelativeDataPath;
end;
procedure TSolverEngine.ProcessData(const ASolver: ISolver);
var
data: TextFile;
@ -97,7 +105,7 @@ var
begin
ASolver.Init;
AssignFile(data, ConcatPaths(['data', ASolver.DataFileName]));
AssignFile(data, ConcatPaths([FRelativeDataPath, ASolver.DataFileName]));
try
reset(data);
while (not EOF(data)) do