Add Board.Position.toString().

This commit is contained in:
Josh Holtrop 2021-02-24 22:18:06 -05:00
parent d6a3de2fd0
commit 03d6f4b55d
2 changed files with 10 additions and 1 deletions

View File

@ -33,6 +33,15 @@ class Board
int new_col = col + dist * (((d % 3) + 1) & 1) * (d / 3 * 2 - 1);
return Position(new_row, new_col);
}
string toString()
{
string s = [
cast(char)('1' + row),
cast(char)('A' + col),
];
return s;
}
}
this(int size)

View File

@ -5,6 +5,6 @@ import pegp.board;
int main(string[] args)
{
Board s = new Board(3);
writeln("Peg Puzzle");
writeln("Peg Puzzle! Position: ", Board.Position(2, 0));
return 0;
}