| 1 | package VANAMBURG::FaceValue; | ||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | =head2 VANAMBURG::FaceValue | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | Represents the face value of a card. See also VANAMBURG::Suit. | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =cut | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head2 name | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | The name of the face value is an full name suchas "Jack", "Ace", etc. | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 6 | has 'name' => ( isa => 'Str', is => 'ro', required => 1 ); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head2 value | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | The value of the card is a number 1 through 13, where Ace is 1, | ||||||||||||||||||||||||||||
| 21 | Two is 2, King is 13, etc. | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =cut | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 6 | has 'value' => ( isa => 'Int', is => 'ro', required => 1 ); | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =head2 abbreviation | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | A single character text abbreviation for the face value. Ace is "A", two is "2", | ||||||||||||||||||||||||||||
| 30 | Jack is "J", etc. | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 6 | has 'abbreviation' => ( isa => 'Str', is => 'ro', required => 1 ); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =head2 equals | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | Returns true (1) when the name and value of this object is the same as that | ||||||||||||||||||||||||||||
| 39 | passed to the method, otherwise returns false (0). | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =cut | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 13 | ▶ | sub equals { | ||||||||||||||||||||||||||
|
Subroutine
equals: called CC=4 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 13 | my ( $self, $other ) = @_; | |||||||||||||||||||||||||||
| 45 | 13 | ▶ | return 0 if ( !defined $other ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 13 | ▶ | if ( $self->name eq $other->name && $self->value == $other->value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->name eq $other->name and $self->value == $other->value
MC/DC0%0/2
$self->name eq $other->name and $self->value == $other->value
$self->name eq $other->name
$self->value == $other->value
Truth table33%1/3
A and B
A= $self->name eq $other->nameB= $self->value == $other->value
| |||||||||||||||||||||||||||||
| 47 | 13 | return 1; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | else { | ||||||||||||||||||||||||||||
| 50 | 0 | return 0; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | 6 | 1; | |||||||||||||||||||||||||||