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 ###');
|
WriteLn('### Advent of Code 2023 ###');
|
||||||
TTrebuchet.Run;
|
TTrebuchet.Run;
|
||||||
TCubeConundrum.Run;
|
TCubeConundrum.Run;
|
||||||
engine := TSolverEngine.Create;
|
engine := TSolverEngine.Create('data');
|
||||||
engine.RunAndFree(TGearRatios.Create);
|
engine.RunAndFree(TGearRatios.Create);
|
||||||
engine.Free;
|
engine.Free;
|
||||||
end;
|
end;
|
||||||
|
|
10
USolver.pas
10
USolver.pas
|
@ -62,7 +62,10 @@ type
|
||||||
{ TSolverEngine }
|
{ TSolverEngine }
|
||||||
|
|
||||||
TSolverEngine = class
|
TSolverEngine = class
|
||||||
|
private
|
||||||
|
FRelativeDataPath: string;
|
||||||
public
|
public
|
||||||
|
constructor Create(const ARelativeDataPath: string);
|
||||||
procedure ProcessData(const ASolver: ISolver);
|
procedure ProcessData(const ASolver: ISolver);
|
||||||
procedure Run(const ASolver: ISolver);
|
procedure Run(const ASolver: ISolver);
|
||||||
procedure RunAndFree(const ASolver: ISolver);
|
procedure RunAndFree(const ASolver: ISolver);
|
||||||
|
@ -90,6 +93,11 @@ end;
|
||||||
|
|
||||||
{ TSolverEngine }
|
{ TSolverEngine }
|
||||||
|
|
||||||
|
constructor TSolverEngine.Create(const ARelativeDataPath: string);
|
||||||
|
begin
|
||||||
|
FRelativeDataPath := ARelativeDataPath;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSolverEngine.ProcessData(const ASolver: ISolver);
|
procedure TSolverEngine.ProcessData(const ASolver: ISolver);
|
||||||
var
|
var
|
||||||
data: TextFile;
|
data: TextFile;
|
||||||
|
@ -97,7 +105,7 @@ var
|
||||||
begin
|
begin
|
||||||
ASolver.Init;
|
ASolver.Init;
|
||||||
|
|
||||||
AssignFile(data, ConcatPaths(['data', ASolver.DataFileName]));
|
AssignFile(data, ConcatPaths([FRelativeDataPath, ASolver.DataFileName]));
|
||||||
try
|
try
|
||||||
reset(data);
|
reset(data);
|
||||||
while (not EOF(data)) do
|
while (not EOF(data)) do
|
||||||
|
|
Loading…
Reference in New Issue