NAME
Games::Sudoku::Component::Table::Cell
SYNOPSIS
my $table = Games::Sudoku::Component::Table->new;
foreach my $cell ($table->cells) {
# Now $cell is a Games::Sudoku::Component::Table::Cell object.
my $item = Games::Sudoku::Component::Table::Item->new(
row => $cell->row,
col => $cell->col,
allowed => [ $cell->allowed ],
);
...
}
# Also, $table->cell(row, col) returns a ::Cell object.
$table->cell(5,5)->value(3);
DESCRIPTION
This module is for a cell of a puzzle board (table). There are several methods here, but some of them are mainly used internally. What you'll actually use are: value, allowed, is_locked, and maybe, row and col.
METHODS
new (hash or hashref)
Creates an object. Below options are mandatory:
- row (integer)
- col (integer)
-
Row/column id of the cell, respectively.
- permission (or
perm
, for short)
See also the base class Games::Sudoku::Component::Base. Actually size related options are required, too.
row
col
Returns a row/column id of the cell respectively, just for convenience.
value (integer)
As a getter, this returns a surface value of the cell, that is, if the cell has a temporary (denied) value, returns it; otherwise, returns a real (allowed) value.
As a setter, you can set (or reset) a value of the cell, regardless of its permission. If the value is not allowed, the value is held as a temporary one. However, it is totally ignored if the cell is locked.
realvalue
Returns a real value of the cell. If the cell has a temporary value, returns 0.
tmpvalue
Returns a temporary value of the cell. If the cell has a real value, returns 0.
allowed
Returns an array of allowed values for the cell.
is_allowed (integer)
Returns true if the argument value is allowed for the cell.
lock
Locks the cell to keep the original puzzle untainted. The locked cell will ignore any new values until it is unlocked.
unlock
Unlocks the cell to make it accept new values.
is_locked
Returns true if the cell is locked.
SEE ALSO
AUTHOR
Kenichi Ishigaki, <ishigaki@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2006 by Kenichi Ishigaki
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.