Added relative data path to TSolverEngine for testing
This commit is contained in:
parent
afa393a168
commit
05e4944521
|
@ -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;
|
||||
|
|
10
USolver.pas
10
USolver.pas
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue