1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| package Questions;
my $ergebnis = 0;
my %question = ( "wie alt ist die Welt?"=>["a. 4 Millards\n", "b. 5 Millards\n", "c. 6 Millards"],
"Was bedeutet BroS?" =>["a. Backup Resol\n","b. Backup Operation\n","c. Backup Resol"],
"wie hoch ist everest?" =>["a. 90m\n","b. 80m\n","c. 50m\n"] );
my @answer = (($question[0],"b"), ($question[1],"c"), ($question[2],"a"));
my %answer = ();
sub new {
my $score = 0;
$class = shift;
my $self = {};
$self ->{question} = shift,
$self-> {answer} = shift;
#my ($ref1, $ref2) =@_;
bless ($self, $class);
return $self;
}
sub setQuestion {
my ($self, $new_question) = @_;
for (my $i = 0; $i<scalar@question; $i++) {
print "$question[$i]\n";
chomp ($antwort = <STDIN>);
#$antwort = lc ($antwort);
if ( lc($antwort) eq lc($answer[$i])){
print "Richtig !\n";
$ergebnis ++;
}
else{
print "Falsche Antwort: \n";
print "Die Antwort ist $answer[$i]\n";
}
$self->{question} = $new_question if defined($new_question);
}
return(@question);
}
sub getResponse {
my ($self) = @_;
return $self->{answer};
}
1; |
Partager