Предмет:
Тип роботи:
Звіт з практики
К-сть сторінок:
46
Мова:
Українська
TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
private
a:string;
x,y:real;
l:integer;
k:boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
begin
Edit1.SetFocus;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
showmessage('Goodbye');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
x:=0; y:=0;l:=-1; k:=false;
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
if Edit1.text<>'0' then Edit1.text:=Edit1.text+'0';
end;
procedure TForm1.Button11Click(Sender: TObject);
begin
if pos(',',Edit1.Text)=0 then Edit1.text:=Edit1.Text+',';
end;
procedure TForm1.Button12Click(Sender: TObject);
begin if (x=0)and(y=0) then begin x:=strtofloat(edit1.Text); Edit1.Text:='';end else begin
y:=strtofloat(edit1.text);
x:=x+y; Edit1.Text:='';
end;
if k then begin x:=x-y; end;
a:=floattostr(x);
l:=1;
end;
procedure TForm1.Button13Click(Sender: TObject);
begin
case l of
1:begin y:=strtofloat(edit1.text); x:=x+y; a:=floattostr(x);k:=true;end;
2:begin y:=strtofloat(edit1.text); x:=x*y; a:=floattostr(x);k:=true;end;
3:begin y:=strtofloat(edit1.text); if y<>0 then begin x:=x/y; a:=floattostr(x);k:=true;end else begin showmessage('error input'); k:=false; x:=0;y:=0;end;end;
4:begin y:=strtofloat(edit1.text); x:=x-y; a:=floattostr(x);k:=true;end;
end;
Edit1.Text:=a; y:=0;
end;
procedure TForm1.Button14Click(Sender: TObject);
begin if (x=0)and(y=0)and(not(k)) then begin x:=strtofloat(edit1.Text); Edit1.Text:='';end else begin
y:=strtofloat(edit1.text);
if not((k)and(x=0)) then x:=x*y; Edit1.Text:='';
end;
if (k)and(x<>0) then begin x:=x/y; end;
a:=floattostr(x);
l:=2;
end;
procedure TForm1.Button15Click(Sender: TObject);
var q:real;
begin q:=strtofloat(edit1.Text);
if q>0 then q:=ln(q);
edit1.Text:=floattostr(q);
end;
procedure TForm1.Button16Click(Sender: TObject);
begin
if (x=0)and(y=0)and(not(k)) then begin x:=strtofloat(edit1.Text); Edit1.Text:='';end else begin
y:=strtofloat(edit1.text);
if not((k)and(x=0))then if y<>0 then begin x:=x/y; Edit1.Text:='';end else begin showmessage('error input'); edit1.Text:=''; x:=0; y:=0; k:=false; end;
end;
if (k)and(x<>0)and(y<>0) then x:=x*y;
a:=floattostr(x);
l:=3;
end;
procedure TForm1.Button17Click(Sender: TObject);
var q:real;
begin q:=strtofloat(edit1.Text);
q:=sqr(q);
edit1.Text:=floattostr(q);
end;
procedure TForm1.Button18Click(Sender: TObject);
begin
edit1.Text:='0';
x:=0; y:=0;l:=0; k:=false;
end;
procedure TForm1.Button19Click(Sender: TObject);
var q:string;
begin q:=edit1.Text;
if (length(q)>1) then delete(q,length(q),1) else q:='0'; x:=strtofloat(q);
edit1.Text:=q;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Edit1.text='0' then Edit1.text:='7' else Edit1.text:=Edit1.text+'7';
end;
procedure TForm1.Button20Click(Sender: TObject);
begin
if (x=0)and(y=0) then begin x:=strtofloat(edit1.Text); Edit1.Text:='';end else begin
y:=strtofloat(edit1.text);
x:=x-y; Edit1.Text:='';
end;
if k then x:=x+y;
a:=floattostr(x);
l:=4;
end;
procedure TForm1.Button21Click(Sender: TObject);
var q:real;
begin q:=strtofloat(edit1.Text);
q:=sqrt(q);
edit1.Text:=floattostr(q);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if Edit1.text='0' then Edit1.text:='8' else Edit1.text:=Edit1.text+'8';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if Edit1.text='0' then Edit1.text:='9' else Edit1.text:=Edit1.text+'9';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if Edit1.text='0' then Edit1.text:='4' else Edit1.text:=Edit1.text+'4';
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if Edit1.text='0' then Edit1.text:='5' else Edit1.text:=Edit1.text+'5';
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
if Edit1.text='0' then Edit1.text:='6' else Edit1.text:=Edit1.text+'6';
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
if Edit1.text='0' then Edit1.text:='3' else Edit1.text:=Edit1.text+'3';
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
if Edit1.text='0' then Edit1.text:='2' else Edit1.text:=Edit1.text+'2';
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
if Edit1.text='0' then Edit1.text:='1' else Edit1.text:=Edit1.text+'1';
end;
end.
17. Анкета
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
ComboBox1: TComboBox;
GroupBox1: TGroupBox;
RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup;
RadioGroup3: TRadioGroup;
RadioGroup4: TRadioGroup;
RadioGroup5: TRadioGroup;
RadioGroup6: TRadioGroup;
Button2: TButton;
GroupBox2: TGroupBox;
RadioGroup7: TRadioGroup;
RadioGroup8: TRadioGroup;
RadioGroup9: TRadioGroup;
RadioGroup10: TRadioGroup;
RadioGroup11: TRadioGroup;
RadioGroup12: TRadioGroup;
memo1: TMemo;
procedure ComboBox1Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
score:integer;
start:boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
s:=Edit1.Text;
if (s='')or(s='Ваше Ім*я') then showmessage('Введіть своє ім*я') else
if combobox1.ItemIndex=-1 then showmessage('Виберіть тест') else
case combobox1.ItemIndex of
0:begin groupbox1.Enabled:=true; groupbox1.Enabled:=true; start:=true; end;
1:begin groupbox1.Visible:=true; groupbox2.Enabled:=true; groupbox2.Visible:=true; start:=true; groupbox1.Enabled:=true; end;
end;
score:=0;
end;
procedure TForm1.Button2Click(Sender: TObject);
var s:string;
begin
if start then begin
case combobox1.ItemIndex of
0: begin s:='Тест з знання столиць Європи';
if radiogroup1.ItemIndex=2 then score:=score+5;
if radiogroup2.ItemIndex=0 then score:=score+5;
if radiogroup3.ItemIndex=2 then score:=score+5;
if radiogroup4.ItemIndex=1 then score:=score+5;
if radiogroup5.ItemIndex=0 then score:=score+5;
if radiogroup6.ItemIndex=0 then score:=score+5;
end;
1:begin s:='Тест з знання столиць Азії';
if radiogroup7.ItemIndex=1 then score:=score+5;
if radiogroup8.ItemIndex=0 then score:=score+5;
if radiogroup9.ItemIndex=3 then score:=score+5;
if radiogroup10.ItemIndex=2 then score:=score+5;
if radiogroup11.ItemIndex=0 then score:=score+5;
if radiogroup12.ItemIndex=2 then score:=score+5;
end;
end;
start:=false;
memo1.Lines.add(s);
s:='Ім*я: '+edit1.Text;
memo1.lines.add(s);
s:='очки:'+inttostr(score)+' з 30';
memo1.lines.add(s);
score:=0;
groupbox1.Enabled:=false;
edit1.Text:='Ваше Ім*я';
combobox1.ItemIndex:=-1;
combobox1.Text:='Виберіть тест';
radiogroup1.ItemIndex:=0;
radiogroup2.ItemIndex:=0;
radiogroup3.ItemIndex:=0;
radiogroup4.ItemIndex:=0;
radiogroup5.ItemIndex:=0;
radiogroup6.ItemIndex:=0;
radiogroup7.ItemIndex:=0;
radiogroup8.ItemIndex:=0;
radiogroup9.ItemIndex:=0;
radiogroup10.ItemIndex:=0;
radiogroup11.ItemIndex:=0;
radiogroup12.ItemIndex:=0;
end else showmessage('Спочтаку розпочніть тестування(нажміть кнопку "Cтарт")');
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
case combobox1.ItemIndex of
0:begin groupbox1.Enabled:=false; groupbox1.Visible:=true; groupbox2.Enabled:=false; groupbox2.Visible:=false;end;
1:begin groupbox2.Enabled:=false; groupbox2.Visible:=true; groupbox1.Enabled:=false; groupbox1.Visible:=true; end;
end;
radiogroup1.ItemIndex:=0;
radiogroup2.ItemIndex:=0;
radiogroup3.ItemIndex:=0;
radiogroup4.ItemIndex:=0;
radiogroup5.ItemIndex:=0;
radiogroup6.ItemIndex:=0;
radiogroup7.ItemIndex:=0;
radiogroup8.ItemIndex:=0;
radiogroup9.ItemIndex:=0;
radiogroup10.ItemIndex:=0;
radiogroup11.ItemIndex:=0;
radiogroup12.ItemIndex:=0;
end;
procedure TForm1.Edit1Click(Sender: TObject);
begin
if edit1.Text='Ваше Ім*я' then edit1.Text:='';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin memo1.Text:='';
radiogroup1.ItemIndex:=0;
radiogroup2.ItemIndex:=0;
radiogroup3.ItemIndex:=0;
radiogroup4.ItemIndex:=0;
radiogroup5.ItemIndex:=0;
radiogroup6.ItemIndex:=0;
radiogroup7.ItemIndex:=0;
radiogroup8.ItemIndex:=0;
radiogroup9.ItemIndex:=0;
radiogroup10.ItemIndex:=0;
radiogroup11.ItemIndex:=0;
radiogroup12.ItemIndex:=0;
groupbox1.Enabled:=false;
groupbox2.Enabled:=false;
form1.Top:=0;
form1.left:=0;
form1.ClientWidth:=screen.Width-18;
form1.clientheight:=screen.Height-85;
start:=false;
end;
end.