line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Math::Tutor::Cmd::Roman::Cmd::Cast; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
17637
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use vars qw(@ISA $VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
App::Math::Tutor::Cmd::Roman::Cmd::Cast - Plugin for casting of roman numerals into natural numbers and vice versa |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
4
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
17
|
1
|
|
|
1
|
|
269
|
use MooX::Cmd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
18
|
1
|
|
|
1
|
|
1558
|
use MooX::Options; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has template_filename => ( |
21
|
|
|
|
|
|
|
is => "ro", |
22
|
|
|
|
|
|
|
default => "twocols" |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
with "App::Math::Tutor::Role::Roman", "App::Math::Tutor::Role::NaturalExercise"; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _build_exercises |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my (@tasks); |
32
|
0
|
|
|
|
|
|
foreach my $i ( 1 .. $self->quantity ) |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
|
|
|
|
|
my @line; |
35
|
0
|
|
|
|
|
|
foreach my $j ( 0 .. 1 ) |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
|
|
|
my ( $a, $b ) = $self->get_natural_number(2); |
38
|
0
|
|
|
|
|
|
push @line, [ $a, $b ]; |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
push @tasks, \@line; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $exercises = { |
44
|
|
|
|
|
|
|
section => "Roman number cast from/to natural number", |
45
|
|
|
|
|
|
|
caption => 'Roman Numerals Casting', |
46
|
|
|
|
|
|
|
label => 'roman_number_cast', |
47
|
|
|
|
|
|
|
header => [ [ 'Cast From Roman Number', 'Cast Into Roman Number' ] ], |
48
|
|
|
|
|
|
|
solutions => [], |
49
|
|
|
|
|
|
|
challenges => [], |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
foreach my $line (@tasks) |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
|
|
|
my ( @solution, @challenge ); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# cast roman into natural number |
57
|
0
|
|
|
|
|
|
my ($a) = @{ $line->[0] }; |
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
push @challenge, sprintf( '$ %s = $', $a ); |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my @way; # remember Frank Sinatra :) |
61
|
0
|
|
|
|
|
|
push @way, "" . $a; |
62
|
0
|
|
|
|
|
|
push @way, int($a); |
63
|
0
|
|
|
|
|
|
push( @solution, '$ ' . join( " = ", @way ) . ' $' ); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# cast natural number into roman |
66
|
0
|
|
|
|
|
|
@way = (); |
67
|
0
|
|
|
|
|
|
($a) = @{ $line->[1] }; |
|
0
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
push @challenge, sprintf( '$ %d = $', $a ); |
69
|
0
|
|
|
|
|
|
push @way, int($a); |
70
|
0
|
|
|
|
|
|
push @way, "" . $a; |
71
|
0
|
|
|
|
|
|
push( @solution, '$ ' . join( " = ", @way ) . ' $' ); |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
push( @{ $exercises->{solutions} }, \@solution ); |
|
0
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
push( @{ $exercises->{challenges} }, \@challenge ); |
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$exercises; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Copyright 2010-2014 Jens Rehsack. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
85
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
86
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |