File Coverage

blib/lib/App/ForKids/LogicalPuzzleGenerator/Variable/Color.pm
Criterion Covered Total %
statement 12 39 30.7
branch 0 2 0.0
condition n/a
subroutine 4 13 30.7
pod 9 9 100.0
total 25 63 39.6


line stmt bran cond sub pod time code
1             package App::ForKids::LogicalPuzzleGenerator::Variable::Color;
2              
3 1     1   5 use strict;
  1         2  
  1         24  
4 1     1   4 use warnings FATAL => 'all';
  1         2  
  1         23  
5 1     1   4 use Carp;
  1         2  
  1         46  
6 1     1   5 use base 'App::ForKids::LogicalPuzzleGenerator::Variable';
  1         1  
  1         407  
7              
8              
9             =head1 NAME
10              
11             App::ForKids::LogicalPuzzleGenerator::Variable::Color
12              
13             =head1 VERSION
14              
15             Version 0.01
16              
17             =cut
18              
19             our $VERSION = '0.01';
20              
21              
22             =head1 SYNOPSIS
23              
24             The module is used by the App::ForKids::LogicalPuzzleGenerator.
25              
26             use App::ForKids::LogicalPuzzleGenerator;
27              
28             =cut
29              
30             our @colors =
31             (
32             "white",
33             "blue",
34             "green",
35             "black",
36             "red",
37             "grey",
38             "yellow"
39             );
40              
41              
42             =head1 SUBROUTINES/METHODS
43              
44             =head2 new
45              
46             =cut
47              
48             sub new
49             {
50 0     0 1   my $class = shift;
51 0           my $this = $class->SUPER::new(@_);
52              
53             # select the colors
54 0           for my $i (0..$$this{amount_of_values}-1)
55             {
56 0           while (1)
57             {
58 0           my $value = $colors[int(rand()*@colors)];
59 0 0         if (!grep {$_ eq $value } @{$$this{selected_values}})
  0            
  0            
60             {
61 0           push @{$$this{selected_values}}, $value;
  0            
62 0           last;
63             }
64             }
65             }
66 0           return $this;
67             }
68              
69             =head2 get_description
70              
71             =cut
72              
73             sub get_description
74             {
75 0     0 1   return "Each has a different favourite color";
76             }
77              
78             =head2 get_description_I
79              
80             =cut
81              
82             sub get_description_I
83             {
84 0     0 1   my ($this, $color) = @_;
85 0           return sprintf("I like %s.", $color);
86             }
87              
88             =head2 get_description_the_one_who
89              
90             =cut
91              
92             sub get_description_the_one_who
93             {
94 0     0 1   my ($this, $color) = @_;
95              
96 0           return sprintf("The one who likes %s", $color);
97             }
98              
99             =head2 get_description_he_does_not
100              
101             =cut
102              
103              
104             sub get_description_he_does_not
105             {
106 0     0 1   my ($this, $color) = @_;
107              
108 0           return sprintf("does not like %s.", $color);
109             }
110              
111             =head2 get_description_I_dont
112              
113             =cut
114              
115             sub get_description_I_dont
116             {
117 0     0 1   my ($this, $color) = @_;
118              
119 0           return sprintf("I don't like %s.", $color);
120             }
121              
122             =head2 get_description_he_likes
123              
124             =cut
125              
126             sub get_description_he_likes
127             {
128 0     0 1   my ($this, $color) = @_;
129 0           return sprintf("likes %s.", $color);
130             }
131              
132             =head2 get_description_X_does_not
133              
134             =cut
135              
136             sub get_description_X_does_not
137             {
138 0     0 1   my ($this, $who, $color) = @_;
139            
140 0           return sprintf("%s does not like %s.", $who, $color);
141             }
142              
143             =head2 get_description_X
144              
145             =cut
146              
147             sub get_description_X
148             {
149 0     0 1   my ($this, $who, $color) = @_;
150 0           return sprintf("%s likes %s.", $who, $color);
151             }
152              
153              
154             =head1 AUTHOR
155              
156             Pawel Biernacki, C<< >>
157              
158             =head1 BUGS
159              
160             Please report any bugs or feature requests to C, or through
161             the web interface at L. I will be notified, and then you'll
162             automatically be notified of progress on your bug as I make changes.
163              
164              
165             =cut
166              
167              
168             1;