Sudoku: move DbgS() functions to the unit where the types concerned are defined.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7244 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
lazarus-bart
2020-01-06 09:37:40 +00:00
parent 8325c001c1
commit 046838f1ce
3 changed files with 26 additions and 22 deletions

View File

@ -38,28 +38,6 @@ implementation
{$R *.lfm} {$R *.lfm}
function DbgS( ASet: TDigitSet): String; overload;
var
D: TDigits;
begin
Result := '[';
for D in ASet do
begin
Result := Result + IntToStr(D) + ',';
end;
if (Result[Length(Result)] = ',') then System.Delete(Result, Length(Result), 1);
Result := Result + ']';
end;
function DbgS(ASquare: TSquare): String; overload;
const
BoolStr: Array[Boolean] of String = ('False','True');
begin
Result := '[Value: ' + IntToStr(ASquare.Value) + ', ';
Result := Result + 'Locked: ' + BoolStr[ASquare.Locked] + ', ';
Result := Result + 'DigitsPossible: ' + DbgS(ASquare.DigitsPossible) + ']';
end;
{ TScratchForm } { TScratchForm }
procedure TScratchForm.FormActivate(Sender: TObject); procedure TScratchForm.FormActivate(Sender: TObject);

View File

@ -81,6 +81,7 @@
<Filename Value="scratchpad.pas"/> <Filename Value="scratchpad.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="ScratchForm"/> <ComponentName Value="ScratchForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="ScratchPad"/> <UnitName Value="ScratchPad"/>
</Unit3> </Unit3>

View File

@ -56,12 +56,37 @@ type
//function Solved: Boolean; //function Solved: Boolean;
end; end;
function DbgS(ASet: TDigitSet): String; overload;
function DbgS(ASquare: TSquare): String; overload;
implementation implementation
const const
cmin : Array[1..9] of Integer = (1, 1, 1, 4, 4, 4, 7, 7, 7); cmin : Array[1..9] of Integer = (1, 1, 1, 4, 4, 4, 7, 7, 7);
cmax : Array[1..9] of Integer = (3, 3, 3, 6, 6, 6, 9, 9, 9); cmax : Array[1..9] of Integer = (3, 3, 3, 6, 6, 6, 9, 9, 9);
function DbgS(ASet: TDigitSet): String; overload;
var
D: TDigits;
begin
Result := '[';
for D in ASet do
begin
Result := Result + IntToStr(D) + ',';
end;
if (Result[Length(Result)] = ',') then System.Delete(Result, Length(Result), 1);
Result := Result + ']';
end;
function DbgS(ASquare: TSquare): String; overload;
const
BoolStr: Array[Boolean] of String = ('False','True');
begin
Result := '[Value: ' + IntToStr(ASquare.Value) + ', ';
Result := Result + 'Locked: ' + BoolStr[ASquare.Locked] + ', ';
Result := Result + 'DigitsPossible: ' + DbgS(ASquare.DigitsPossible) + ']';
end;
{ {
Counts the number of TDigitSet in ASet. Counts the number of TDigitSet in ASet.
aValue only has meaning if Result = 1 (which means this cell is solved) aValue only has meaning if Result = 1 (which means this cell is solved)