Thread Vokabeltrainer
(17 answers)
Opened by Futureflo at 2011-03-06 23:06
Danke für die Antworten!
Also mein Unter-Programm sieht jetzt so aus. Gerne Verbesserungsvorschläge wenn jemand was zu verbessern hat. [code=perl] Code (perl): (dl
)
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 54 55 56 57 58 59 60 61 62 63 #!/usr/bin/perl use strict; use warnings; open (LESEN, "Vokabeln.txt")||die "Die Datei konnte nicht gefunden werden"; my $vokabeln=<LESEN>; close (LESEN); my @vokabeln_array = split (/:+/, $vokabeln); open (LESEN, "Loesung.txt")||die "Die Datei konnte nicht gefunden werden"; my $loesung=<LESEN>; close (LESEN); my @loesung_array = split (/:+/, $loesung); my$anzahl_loesung= $#loesung_array; my$anzahl_vokabeln= $#vokabeln_array; my @alle_versuche; my @alle_vokabeln; my $durchgaenge=0; while ($durchgaenge<($anzahl_loesung+1)) { my $zahl=0+rand($anzahl_vokabeln); print"Translate the word $vokabeln_array[$zahl]\n"; my $eingabe = <STDIN>; chomp $eingabe; push @alle_versuche, $eingabe; push @alle_vokabeln, $vokabeln_array[$zahl]; if ($eingabe eq $loesung_array[$zahl]) { print"The translation is correct!\n"; $durchgaenge++; } else { print"The translation is incorrect\n"; print"Do you want to save the incorrect word and answer?\n"; print"(1)Yes (2)No\n"; my $antwort=<STDIN>; chomp$antwort; if($antwort eq 1){ open(SCHREIB,">nichtgekonnte.txt"); print SCHREIB ">>Wrong:\n"; print SCHREIB join "\n", @alle_vokabeln; print SCHREIB "\n\n"; print SCHREIB ">>Answer:\n"; print SCHREIB join "\n", @alle_versuche; close(SCHREIB); $durchgaenge++; } else{ $durchgaenge++; } } } Last edited: 2011-03-07 11:42:14 +0100 (CET) |