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


QNA documentation  | view source Contained in the QNA distribution.

Index


NAME

Top

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

SYNOPSIS

Top

	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;




	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');


QNA documentation  | view source Contained in the QNA distribution.