Код програми:
program Project1;
uses
Forms,
Windows,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {Form3},
Unit4 in 'Unit4.pas' {Form4},
Unit5 in 'Unit5.pas' {Form5};
{$R *.res}
begin
Application.Title:='CostMaster';
Application.CreateForm(TForm2, Form2);
Form2.Free;
Application.CreateForm(TForm3, Form3);
Form3.Show;
Form3.Repaint;
Sleep(3000);
Form3.Hide;
Form3.Free;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.Show;
Application.CreateForm(TForm2, Form2);
Application.CreateForm(TForm4, Form4);
Application.CreateForm(TForm5, Form5);
Application.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls;
type
TForm1 = class(TForm)
img1: TImage;
lbl1: TLabel;
edt1: TEdit;
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
x:integer;
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
if edt1.text='gnom' then
begin
Form2.Show;
Form1.Hide;
Form1.Free;
end;
if edt1.text<>'gnom' then
begin
x:=x-1;
lbl1.Caption:='Ключ хибний, залишилося '+IntToStr(x)+' спроб';
end;
if x=0 then Form1.Close;
end;
begin
x:=3;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus, jpeg;
type
TForm2 = class(TForm)
edt1: TEdit;
edt2: TEdit;
rg1: TRadioGroup;
lbl1: TLabel;
lbl2: TLabel;
rg2: TRadioGroup;
btn1: TButton;
lbl3: TLabel;
mm1: TMainMenu;
edt3: TEdit;
lbl4: TLabel;
edt4: TEdit;
lbl5: TLabel;
btn2: TButton;
btn3: TButton;
btn4: TButton;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
img1: TImage;
procedure rg1Click(Sender: TObject);
procedure rg2Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure btn4Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure edt1KeyPress(Sender: TObject; var Key: Char);
procedure edt3KeyPress(Sender: TObject; var Key: Char);
procedure edt2KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
y,t:real;
Form2: TForm2;
implementation
uses Unit4, Unit5, Unit1;
{$R *.dfm}
procedure TForm2.rg1Click(Sender: TObject);
begin
case rg1.ItemIndex of
0: begin
y:=11.55;
end;
1: begin
y:=11.30;
end;
2: begin
y:=11.16;
end;
3: begin
y:=10.78;
end;
4: begin
y:=10.27;
end;
end;
end;
procedure TForm2.rg2Click(Sender: TObject);
begin
case rg2.ItemIndex of
0: begin
t:=1.0;
end;
1: begin
t:=1.4;
end;
2: begin
t:=1.2;
end;
end;
end;
procedure TForm2.btn2Click(Sender: TObject);
begin
if edt1.text='' then
begin
ShowMessage('Ââåä³òü øëÿõ');
edt1.text:='0';
end;
if edt3.text='' then
begin
ShowMessage('Введ³ть данн³ з тех.паспорту');
edt3.Text:='0';
end;
if rg1.ItemIndex=-1 then
ShowMessage('Вибер³ть марку пального');
if rg2.ItemIndex=-1 then
ShowMessage('Степ³нь шляхового навантаження');
edt4.Text:=FloatToStr(StrToFloat(edt1.text)*StrToFloat(edt3.text)/100.0*y*t);
end;
procedure TForm2.btn1Click(Sender: TObject);
begin
if edt2.text='' then ShowMessage('Ââåä³òü ë³òðàæ');
if edt2.text<>'' then Form4.ShowModal;
end;
procedure TForm2.btn4Click(Sender: TObject);
begin
Form5.ShowModal;
end;
procedure TForm2.btn3Click(Sender: TObject);
begin
edt1.Text:='';
edt2.Text:='';
edt3.Text:='';
edt4.Text:='';
rg1.ItemIndex:=-1;
rg2.ItemIndex:=-1;
edt1.SetFocus;
end;
procedure TForm2.N2Click(Sender: TObject);
begin
ShowMessage('Просто введ³ть запитуванн³ характеристики вашого авто, обер³ть марку бензину, обер³ть степ³нь навантаження дороги ³ введ³ть довжину шляху');
end;
procedure TForm2.N4Click(Sender: TObject);
begin
Halt;
end;
procedure TForm2.N3Click(Sender: TObject);
begin
ShowMessage('Програма розроблялася для людей, як³ завжди хочуть бути у курс³ сво¿х можливих витрат на пальне. Автор: Корабльов В³ктор');
end;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Halt;
end;
procedure TForm2.edt1KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0'..'9',',',#8]) then key:=#0;
end;
procedure TForm2.edt3KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0'..'9',',',#8]) then key:=#0;
end;
procedure TForm2.edt2KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0'..'9',',',#8]) then key:=#0;
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls;
type
TForm3 = class(TForm)
img1: TImage;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
end.
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls;
type
TForm4 = class(TForm)
img1: TImage;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
end.
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls;
type
TForm5 = class(TForm)
img1: TImage;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
{$R *.dfm}
end.