Bu makalemizde delphide bir sayısal loto uygulaması yapacağız.
Bu programda amaç, 1-49 arasında 6 farklı rakamlar belirtilen çekiliş dizisinde tutulmaktadır. Girilen kolon sayısına göre bilgisayar rasgele 1 -49 arasında 6 farklı rakamlar oynamaktadır. Bu oynanan kolonları çeklişle karşılaştırmaktır.
Unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, Buttons, ExtCtrls;typeTForm1 = class(TForm)Edit1: TEdit;Label1: TLabel;ListBox1: TListBox;Edit2: TEdit;Label2: TLabel;Label3: TLabel;Label4: TLabel;Label5: TLabel;Label6: TLabel;Label7: TLabel;Label8: TLabel;Label9: TLabel;Label10: TLabel;Label11: TLabel;Label12: TLabel;Label13: TLabel;Label14: TLabel;Timer1: TTimer;SpeedButton1: TSpeedButton;SpeedButton2: TSpeedButton;Timer2: TTimer;Label15: TLabel;Label16: TLabel;procedure FormCreate(Sender: TObject);procedure Timer1Timer(Sender: TObject);procedure SpeedButton1Click(Sender: TObject);procedure SpeedButton2Click(Sender: TObject);procedure Timer2Timer(Sender: TObject);procedure Label15Click(Sender: TObject);procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);procedure Label15MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);procedure Label15MouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;a:array[1..6] of integer;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
ListBox1: TListBox;
Edit2: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Timer1: TTimer;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
Timer2: TTimer;
Label15: TLabel;
Label16: TLabel;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Label15Click(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Label15MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Label15MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a:array[1..6] of integer;
b:array[1..6] of integer;
sayac,seffaf:integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
AlphaBlend:=true;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
seffaf:=seffaf+5;
AlphaBlendValue:=seffaf;
if seffaf=255 then
timer1.Enabled:=false;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
i,j,deger:integer;
begin
randomize;
a[1]:=random(49)+1;
a[2]:=random(49)+1;
a[3]:=random(49)+1;
a[4]:=random(49)+1;
a[5]:=random(49)+1;
a[6]:=random(49)+1;
for i:=1 to 6 do
for j:=i+1 to 6 do
if a[i]=a[j] then a[i]:=a[i]+1;
for i:=1 to 6 do
for j:=i+1 to 6 do
if a[i]>a[j] then
begin
deger:=a[i];
a[i]:=a[j];
a[j]:=deger;
end;
edit1.Text:=inttostr(a[1])+? ?+inttostr(a[2])+? ?+inttostr(a[3])+? ?+inttostr(a[4])+? ?+inttostr(a[5])+? ?+inttostr(a[6]);
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
var
i,j,deger,k:integer;
begin
listbox1.Clear;
label9.Caption:=?0?;
label10.Caption:=?0?;
label11.Caption:=?0?;
label12.Caption:=?0?;
label13.Caption:=?0?;
label14.Caption:=?0?;
for k:=1 to strtoint(edit2.text) do
Devamını Oku