| 1 | package Games::Sudoku::Component::Table::Item; | ||||||||||||||||||||
| 2 | { | ||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 6 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 6 | our $VERSION = '0.01'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 442 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||
| 10 | 442 | my $class = shift; | |||||||||||||||||||
| 11 | 442 | ▶ | my $this = bless {}, (ref $class || $class); | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 442 | ▶ | my %options = ref $_[0] ? %{ $_[0] } : @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 442 | ▶ | croak "Row is undefined" unless defined $options{row}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 16 | 440 | ▶ | croak "Col is undefined" unless defined $options{col}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 17 | 439 | ▶ | croak "Allowed is undefined" unless defined $options{allowed}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 18 | croak "Allowed should be array_ref" | ||||||||||||||||||||
| 19 | 438 | ▶ | if ref $options{allowed} ne 'ARRAY'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 438 | $this->{row} = $options{row}; | |||||||||||||||||||
| 22 | 438 | $this->{col} = $options{col}; | |||||||||||||||||||
| 23 | 438 | $this->{allowed} = $options{allowed}; | |||||||||||||||||||
| 24 | 438 | $this->{value} = $options{value}; | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 438 | $this; | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 418 | ▶ | sub row { $_[0]->{row} } | ||||||||||||||||||
|
Subroutine
row: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 30 | 418 | ▶ | sub col { $_[0]->{col} } | ||||||||||||||||||
|
Subroutine
col: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 31 | 83 | ▶ | sub value { $_[0]->{value} } | ||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 32 | 3 | ▶ | sub allowed { @{ $_[0]->{allowed} } } | ||||||||||||||||||
|
Subroutine
allowed: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 311 | ▶ | sub random_value { | ||||||||||||||||||
|
Subroutine
random_value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 35 | 311 | my $this = shift; | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 311 | my @allowed = @{ $this->{allowed} }; | |||||||||||||||||||
| 38 | 311 | my $value = splice(@allowed, int(rand(@allowed)), 1); | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 311 | $this->{allowed} = \@allowed; | |||||||||||||||||||
| 41 | 311 | $this->{value} = $value; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 311 | $value; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 1 | ▶ | sub as_string { | ||||||||||||||||||
|
Subroutine
as_string: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||
| 47 | 1 | my $this = shift; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 1 | ▶ | my $row = $this->{row} || 0; | ||||||||||||||||||
|
Condition50%1/2
$this->{'row'} || 0
MC/DC0%0/1
$this->{'row'} || 0
$this->{'row'}
Truth table50%1/2
A
A= $this->{'row'}
| |||||||||||||||||||||
| 50 | 1 | ▶ | my $col = $this->{col} || 0; | ||||||||||||||||||
|
Condition50%1/2
$this->{'col'} || 0
MC/DC0%0/1
$this->{'col'} || 0
$this->{'col'}
Truth table50%1/2
A
A= $this->{'col'}
| |||||||||||||||||||||
| 51 | 1 | ▶ | my $value = $this->{value} || 0; | ||||||||||||||||||
|
Condition50%1/2
$this->{'value'} || 0
MC/DC0%0/1
$this->{'value'} || 0
$this->{'value'}
Truth table50%1/2
A
A= $this->{'value'}
| |||||||||||||||||||||
| 52 | 1 | my @allowed = @{ $this->{allowed} }; | |||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 1 | sprintf('(%d, %d): %d (allowed: %s)', | |||||||||||||||||||
| 55 | $row, $col, $value, join(', ', @allowed), | ||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 6 | 1; | |||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||