From 05e494452119a533dc445707fccbf9f0109d24ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Mon, 4 Dec 2023 16:29:32 +0100 Subject: [PATCH] Added relative data path to TSolverEngine for testing --- AdventOfCode.lpr | 2 +- USolver.pas | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/AdventOfCode.lpr b/AdventOfCode.lpr index 83e2617..3a77065 100644 --- a/AdventOfCode.lpr +++ b/AdventOfCode.lpr @@ -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; diff --git a/USolver.pas b/USolver.pas index 5eacddf..d47a893 100644 --- a/USolver.pas +++ b/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