Richard Foley > QNA_0.5 > MathsQuestion

Download:
QNA_0.5.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Source  

NAME ^

MathsQuestion - Supplier of simple maths questions to Question or Quiz.

SYNOPSIS ^

        use MathsQuestion;
        use Quiz;
        use strict;
        my @list;
        my @qs = qw(add subtract multiply divide); 
        foreach (@qs) {
                my ($qst, $ans) = MathsQuestion->new($_, 1);
                push (@list, $qst, $ans);
        }
        my $quiz = Quiz->new(@list);
        $quiz->prompt('Question: '); #going to use our own prompt.
        while ($quiz->unanswered_questions) {
                print $quiz->next_question, "\n"; 
                $_ = <>;
                if ($quiz->check_guess($_)) {
                        print $quiz->{right_message};
                } else {
                        print $quiz->{wrong_message};
                }
        }
        $quiz->finished;
        print $quiz->results;
        exit;
new
        Create new object:
        
        my $m = MathsQuestion->new($func, $level); 
        
        #$level is either 1, 2 or 3, default is 1.
        
        #add, subtract, multiply, divide
        #? or a, s, m, d 
        #? or + - x / %(o)
        
        my $mx = MathsQuestion->new('m');