unit Unit5;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, jpeg, ExtCtrls;

type
  TForm5 = class(TForm)
    Memo1: TMemo;
    Image1: TImage;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Button1: TButton;
    Memo2: TMemo;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form5: TForm5;

implementation

uses Unit4, Unit6;

{$R *.dfm}
type
Trij = array [1..8] of string;
Tcol = array [1..18] of Trij;
var
rijcol : Tcol;
infile : textfile;

procedure TForm5.Button1Click(Sender: TObject);
var
  teller1, teller2 : integer;
  rijTekst : string;
begin
  assignfile (infile, 'Raadsel.txt');
  reset (infile);
  memo1.Clear;
  for teller1 := 1 to 8 do
  begin
    rijtekst := '';
    for teller2 := 1 to 8 do
    begin
       read (infile, rijcol [teller1, teller2]);
       rijtekst := rijtekst +rijcol [teller1, teller2]
    end;
    memo1.lines.add (rijtekst);
  ReadLn (infile);
  end;
  closefile (infile);

end;

procedure TForm5.Button2Click(Sender: TObject);
var
goed: integer;
Fout: integer;
var1, var2: string;
result: real;
outfile: textfile;
begin
goed:= 0;
fout:= 0;
 if (edit1.text = 'kat') xor (edit1.text = 'Kat')then
  begin
   goed:= goed + 1;
  end
   else
  begin
   fout:= fout + 1;
  end;

 if (edit2.text = 'Aap') xor (edit2.text = 'Aap')then
  begin
   goed:= goed + 1;
  end
   else
  begin
   fout:= fout + 1;
  end;

 if (edit3.text = 'Tijger') xor (edit3.text = 'tijger')then
  begin
   goed:= goed + 1;
  end
   else
  begin
   fout:= fout + 1;
  end;

 if (edit4.text = 'Zeehond') xor (edit4.text = 'zeehond') then
  begin
   goed:= goed + 1;
  end
   else
  begin
   fout:= fout + 1;
  end;

 if (edit5.text = 'Ezel') xor (edit5.text = 'ezel') xor (edit5.text = 'Eend') xor (edit5.text = 'eend') then
  begin
   goed:= goed + 1;
  end
   else
  begin
   fout:= fout + 1;
  end;

 if (edit6.text = 'Ezel') xor (edit6.text = 'ezel') xor (edit6.text = 'Eend') xor (edit6.text = 'eend') then
  begin
   goed:= goed + 1;
  end
   else
  begin
   fout:= fout + 1;
  end;

 if (edit7.text = 'Leeuw') xor (edit7.text = 'leeuw') then
  begin
   goed:= goed + 1;
  end
   else
  begin
   fout:= fout + 1;
  end;

 if (edit8.text = 'Wolf') xor (edit8.text = 'wolf') then
  begin
   goed:= goed + 1;
  end
   else
  begin
   fout:= fout + 1;
  end;

 if (edit9.text = 'Vogel') xor (edit9.text = 'vogel') then
  begin
   goed:= goed + 1;
  end
   else
  begin
   fout:= fout +1;
  end;
  var2:= 'RAADSEL:   Uitkomsten ' + edit1.text + ' (Kat), ' + edit2.text+ ' (Aap), ' + edit3.text + ' (Tijger), '+ edit4.text + ' (Zeehond), ' + edit5.text+ ' (Ezel of Eend), ' + edit6.text + ' (Ezel of Eend), ' + edit7.text + ' (Leeuw), ' + edit8.text + ' (Wolf), ' + edit9.text + ' (Vogel)';
  Assignfile(outfile, 'UitkomstenKind.txt');
  Append(outfile);
  WriteLn(outfile, Var2);
  closefile(outfile);

  result:= (goed / (goed + fout)) * 100;
  Showmessage ('Jij hebt ' + (intToStr(goed)) + ' goed en ' + (IntToStr(fout))+ ' fout!');
  Var1 := '           In totaal '+ IntToStr(goed)+ ' goed en '+IntToStr(fout) +' fout.  RESULT is '+FloatToStr(result)+ '% goed.';

  Assignfile(outfile, 'UitkomstenKind.txt');
  Append(outfile);
  WriteLn(outfile, Var1);
  closefile(outfile);
  form6.show;
 end;
end.
