line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Math::Tutor::Role::VulFrac; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1876
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
App::Math::Tutor::Role::VulFrac - role for vulgar fraction numbers |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=cut |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
13
|
1
|
|
|
1
|
|
954
|
use App::Math::Tutor::Numbers; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
326
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.004'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _check_vulgar_fraction |
18
|
|
|
|
|
|
|
{ |
19
|
395
|
100
|
100
|
395
|
|
11013
|
$_[1]->num >= 2 and $_[1]->denum >= 2 and $_[1]->num % $_[1]->denum != 0; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
requires "format"; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _guess_vulgar_fraction |
25
|
|
|
|
|
|
|
{ |
26
|
395
|
|
|
395
|
|
400
|
my ( $max_num, $max_denum, $neg ) = ( @{ $_[0]->format }, $_[0]->negativable ); |
|
395
|
|
|
|
|
1095
|
|
27
|
395
|
|
|
|
|
457
|
my ( $num, $denum ); |
28
|
395
|
50
|
|
|
|
1081
|
( $num, $denum ) = |
29
|
|
|
|
|
|
|
$neg |
30
|
|
|
|
|
|
|
? ( int( rand( $max_num * 2 ) - $max_num ), int( rand( $max_denum * 2 ) - $max_denum ) ) |
31
|
|
|
|
|
|
|
: ( int( rand($max_num) ), int( rand($max_denum) ) ); |
32
|
|
|
|
|
|
|
return |
33
|
395
|
|
|
|
|
8720
|
VulFrac->new( num => $num, |
34
|
|
|
|
|
|
|
denum => $denum ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 METHODS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 get_vulgar_fractions |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Returns as many vulgar fractions as requested. Does Factory :) |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_vulgar_fractions |
46
|
|
|
|
|
|
|
{ |
47
|
90
|
|
|
90
|
1
|
125
|
my ( $self, $amount ) = @_; |
48
|
90
|
|
|
|
|
85
|
my @result; |
49
|
|
|
|
|
|
|
|
50
|
90
|
|
|
|
|
192
|
while ( $amount-- ) |
51
|
|
|
|
|
|
|
{ |
52
|
180
|
|
|
|
|
165
|
my $vf; |
53
|
|
|
|
|
|
|
do |
54
|
180
|
|
|
|
|
167
|
{ |
55
|
200
|
|
|
|
|
380
|
$vf = $self->_guess_vulgar_fraction; |
56
|
|
|
|
|
|
|
} while ( !$self->_check_vulgar_fraction($vf) ); |
57
|
|
|
|
|
|
|
|
58
|
180
|
|
|
|
|
756
|
push @result, $vf; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
90
|
|
|
|
|
273
|
return @result; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Copyright 2010-2014 Jens Rehsack. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
69
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
70
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |