Додатки: Додаток1. Код програми
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls, MPlayer;
type
TForm1 = class(TForm)
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label5: TLabel;
Label6: TLabel;
MediaPlayer1: TMediaPlayer;
procedure Label5Click(Sender: TObject);
procedure Label2Click(Sender: TObject);
procedure Label3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Label6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2, Unit3, Unit5;
{$R *.dfm}
procedure TForm1.Label5Click(Sender: TObject);
begin
form1.Close;
end;
procedure TForm1.Label2Click(Sender: TObject);
begin
form1.Visible:=false;
form2.visible:=true;
end;
procedure TForm1.Label3Click(Sender: TObject);
begin
form1.Visible:=false;
form3.visible:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
mediaplayer1.Play;
end;
procedure TForm1.Label6Click(Sender: TObject);
begin
form1.Visible:=false;
form5.visible:=true;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls;
type
TForm2 = class(TForm)
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Timer1: TTimer;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
procedure Label1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
var z,a1,a2,a3,q,st:Integer;
implementation
uses Unit1, Unit4;
{$R *.dfm}
procedure TForm2.Label1Click(Sender: TObject);
var outfile: TextFile;
begin
form2.Close;
form1.visible:=true;
AssignFile(outfile, 'c:\автомат.txt');
Append(outfile);
write(outfile, Рахунок ='); writeln(outfile, q);
write(outfile, 'час ='); writeln(outfile, z);
CloseFile(outfile);
end;
procedure TForm2.Timer1Timer(Sender: TObject);
begin
z:=z+1;
label3.Caption:='час:'+IntToStr(z);
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true;
st:=StrToInt(Edit1.Text);
q:=q-st;
a1:=random(10);
label4.Caption:=IntToStr(a1);
a2:=random(10);
label5.Caption:=IntToStr(a2);
a3:=random(10);
label6.Caption:=IntToStr(a3);
if a1=a2 then
begin
q:=q+(3*st);
end;
if a1=a3 then
begin
q:=q+(3*st);
end;
if a2=a3 then
begin
q:=q+(3*st);
end;
label7.Caption:=рахунок='+IntToStr(q);
if q<=0 then
begin
form2.Close;
form4.visible:=true;
q:=50;
z:=0;
end;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
q:=50;
z:=0;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
q:=50;
z:=0;
a1:=0;
a2:=0;
a3:=0;
label7.Caption:='рахунок='+IntToStr(q);
label3.Caption:=IntToStr(z);
label4.Caption:=IntToStr(a1);
label5.Caption:=IntToStr(a2);
label6.Caption:=IntToStr(a3);
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
Label1: TLabel;
Button2: TButton;
Label2: TLabel;
Edit1: TEdit;
Image1: TImage;
Edit2: TEdit;
Edit3: TEdit;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit4: TEdit;
Label8: TLabel;
Label9: TLabel;
Timer2: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer2Timer(Sender: TObject); private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
var e,ryl,num3,num2,num1,st,tim:Integer;
implementation
uses Unit1, Unit4, Unit2;
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
var outfile: TextFile;
begin
form3.Close;
form1.visible:=true;
AssignFile(outfile, 'c:\автомат.txt');
Append(outfile);
write(outfile, рахунок ='); writeln(outfile, ryl);
write(outfile, 'час ='); writeln(outfile, tim);
CloseFile(outfile);
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
timer2.Enabled:=true;
st:=StrToInt(Edit4.Text);
e:=random(37);
label1.Caption:=IntToStr(e);
ryl:=ryl-st;
num1:=StrToInt(Edit1.Text);
num2:=StrToInt(Edit2.Text);
num3:=StrToInt(Edit3.Text);
if num1=e then
begin
ryl:=ryl+(st*36);
end;
if num2=e then
begin
ryl:=ryl+(st*36);
end;
if num3=e then
begin
ryl:=ryl+(st*36);
end;
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
label7.Caption:=IntToStr(ryl);
if ryl<=0 then
begin
form3.Close;
form4.visible:=true;
end;
end;
procedure TForm3.FormCreate(Sender: TObject);
begin
ryl:=1000;
if ryl=0 then
begin
form3.Close;
form4.visible:=true;
end;
if ryl<0 then
begin
form3.Close;
form4.visible:=true;
end;
end;
procedure TForm3.Timer2Timer(Sender: TObject);
begin
tim:=tim+1;
label9.Caption:='час:'+IntToStr(tim);
end;
end.
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm4 = class(TForm)
Label1: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
uses Unit2, Unit1;
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
begin
form4.Close;
form2.visible:=true;
end;
procedure TForm4.Button2Click(Sender: TObject);
begin
form4.Close;
form1.visible:=true;
end;
end.
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm5 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Memo2: TMemo;
Button2: TButton;
Memo1: TMemo;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm5.Button1Click(Sender: TObject);
begin
form1.visible:=true;
form5.Visible:=false;
end;
procedure TForm5.Button2Click(Sender: TObject);
var outfile: TextFile;
var q,st:Integer;
byf,qw : string;
begin
AssignFile(outfile,'c:\автомат.txt');
Reset(outfile);
readln(outfile, byf);
Memo1.Lines.Add(byf);
readln(outfile, qw);
Memo1.Lines.Add(qw);
CloseFile(outfile);
end;
procedure TForm5.Button3Click(Sender: TObject);
var outfile: TextFile;
byf1,qw1 : string;
begin
AssignFile(outfile,'c:\рулетка.txt');
Reset(outfile);
readln(outfile, byf1);
Memo2.Lines.Add(byf1);
readln(outfile, qw1);
Memo2.Lines.Add(qw1);
CloseFile(outfile);
end;
end.