unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Image300: TImage;
ListBox1: TListBox;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen}
public
{ Public-Deklarationen}
end;
TKarte =
class(TObject)
id:
string;
vorseite, rueckseite, akt: Timage;
constructor create(x,y:integer; idn,filename:
string);
procedure drehen(sender:TObject);
end;
var
Form1: TForm1;
karte: tkarte;
x,y,z,n,tmp,compare1,compare2: integer;
k:integer=0;
s,name1,name2,idn:
string;
const
kartenzahl=80;
implementation
{$R *.DFM}
procedure tkarte.drehen(sender:TObject);
begin
k:=k+1;
if k=1
then begin
name1:=vorseite.
Name;
delete(name1,1,5);
compare1:=strtoint(name1);
if compare1>39
then compare1:=compare1-40;
end;
if k=2
then begin
name2:=vorseite.
name;
delete(name2,1,5);
compare2:=strtoint(name2);
if compare2>39
then compare2:=compare2-40;
form1.button1.enabled:=true;
end;
if k<3
then begin
akt.hide;
if akt=vorseite
then akt:=rueckseite
else akt:=vorseite;
akt.show;
end else begin
showmessage('
Mogeln nicht gestattet!');
form1.button1.enabled:=true;
end;
end;
constructor tkarte.create(x,y:integer; idn,filename:
string);
begin
vorseite:=TImage.create(form1);
with vorseite
do begin
parent:=form1;
top:=y; left:=x; autosize:=true;
picture.loadfromfile(filename);
onclick:=drehen;
name:='
image'+idn;
hide;
end;
rueckseite:=TImage.create(form1);
with rueckseite
do begin
parent:=form1;
top:=y; left:=x; autosize:=true;
picture.loadfromfile('
Bilder\Icon00.ico');
onclick:=drehen;
show;
end;
akt:=rueckseite;
end;
procedure zufallsliste;
var i,j,z: integer; neu: boolean;
begin
randomize;
with form1.listbox1
do begin
items.add(inttostr(random(kartenzahl)));
for i:=1
to kartenzahl-1
do begin
repeat
neu:=true;
z:=random(kartenzahl);
for j:=0
to items.count-1
do
if strtoint(items[j])=z
then begin neu:=false; break
end;
until neu;
items.add(inttostr(z));
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var idn:
string; i,j,w: integer;
begin
zufallsliste;
n:=0; x:=50; y:=20;
for i:=1
to 8
do begin
for j:=1
to 10
do begin
z:=strtoint(listbox1.items[n]);
idn:=inttostr(z);
w:=z;
if w>39
then begin ;w:=w-40;
end ;
karte:=tkarte.create(x,y,idn,'
Bilder\icon'+inttostr(w)+'
.ico');
x:=x+50;
inc(n);
end;
y:=y+50;
x:=50;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
button1.enabled:=false;
k:=0;
If compare1=compare2
then begin
showmessage('
Treffer!');
end;
end;
end.