Witam ponownie,
aktualnie moje zadanie jest w następującym stadium: http://wrzucacz.pl/file/1661300440030
przypominam, że ma wyglądać identycznie jak to: http://wrzucacz.pl/file/8201300361092
Aktualnie mam problem z komunikatami i z obliczeniami, bo działa dla ruchu jednostajnego jak jest checkbox wlaczony a ma dziala tez w pozostalych 3 wariantach,
poza tym mam problem z przypisaniem skrótów klawiszowych.
unit droganasza;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
Edit5: TEdit;
Label5: TLabel;
RadioGroup1: TRadioGroup;
Label6: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure CheckBox1Click(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if ( not( Key in ['0'..'9',DecimalSeparator,#8,'-'] )) then Key:=#0
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
Edit1.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 0);
Label6.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 0);
Edit4.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 1);
Edit6.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 1);
Label7.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 1);
Label2.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 1);
end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
Edit1.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 0);
Edit2.Visible:=(RadioGroup1.ItemIndex = 0);
Edit3.Visible:=(RadioGroup1.ItemIndex = 0);
Label6.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 0);
Label3.Visible:=(RadioGroup1.ItemIndex = 0);
Label4.Visible:=(RadioGroup1.ItemIndex = 0);
Edit4.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 1);
Edit6.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 1);
Edit7.Visible:=(RadioGroup1.ItemIndex = 1);
Edit8.Visible:=(RadioGroup1.ItemIndex = 1);
Label7.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 1);
Label2.Visible:=(CheckBox1.Checked)and(RadioGroup1.ItemIndex = 1);
Label8.Visible:=(RadioGroup1.ItemIndex = 1);
Label9.Visible:=(RadioGroup1.ItemIndex = 1);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
s01, t1, v1, s02, v02, t2, v2, a2, jednostajny, jednostajny2, przyspieszony2, przyspieszony: Real;
begin
if (CheckBox1.Checked)and(RadioGroup1.ItemIndex = 0) then
if ( Edit1.Text='') then begin
Application.MessageBox('Brak parametru s0', 'Informacja', MB_OK+MB_ICONError);
Edit1.SetFocus; end;
if ( Edit2.Text='') then begin
Application.MessageBox('Brak parametru t', 'Informacja', MB_OK+MB_ICONError);
Edit2.SetFocus; end;
if ( Edit3.Text='') then begin
Application.MessageBox('Brak parametru v', 'Informacja', MB_OK+MB_ICONError);
Edit3.SetFocus; end
else begin
s01 := StrToFloat(Edit1.Text);
t1 := StrToFloat(Edit2.Text);
v1 := StrToFloat(Edit3.Text);
jednostajny2 := s01*t1+v1;
Edit5.Text := FloatToStr (jednostajny2);
end;
if (RadioGroup1.ItemIndex = 0) then
if ( Edit2.Text='') then begin
Application.MessageBox('Brak parametru t', 'Informacja', MB_OK+MB_ICONError);
Edit2.SetFocus; exit; end;
if ( Edit3.Text='') then begin
Application.MessageBox('Brak parametru v', 'Informacja', MB_OK+MB_ICONError);
Edit3.SetFocus; exit; end
else begin
t1 := StrToFloat(Edit2.Text);
v1 := StrToFloat(Edit3.Text);
jednostajny := t1*v1;
Edit5.Text := FloatToStr (jednostajny);
end;
if (CheckBox1.Checked)and(RadioGroup1.ItemIndex = 1) then
if ( Edit4.Text='') then begin
Application.MessageBox('Brak parametru s0', 'Informacja', MB_OK+MB_ICONError);
Edit4.SetFocus; exit; end;
if ( Edit6.Text='') then begin
Application.MessageBox('Brak parametru v0', 'Informacja', MB_OK+MB_ICONError);
Edit6.SetFocus; exit; end;
if ( Edit7.Text='') then begin
Application.MessageBox('Brak parametru t', 'Informacja', MB_OK+MB_ICONError);
Edit7.SetFocus; exit; end;
if ( Edit8.Text='') then begin
Application.MessageBox('Brak parametru a', 'Informacja', MB_OK+MB_ICONError);
Edit8.SetFocus; exit; end
else begin
s02 := StrToFloat(Edit4.Text);
v02 := StrToFloat(Edit6.Text);
t2 := StrToFloat(Edit7.Text);
a2 := StrToFloat(Edit8.Text);
przyspieszony2 := s02+(v02*t2)+(a2*sqr(t2)/2);
Edit5.Text := FloatToStr (przyspieszony2);
end;
if (RadioGroup1.ItemIndex = 1) then
if ( Edit7.Text='') then begin
Application.MessageBox('Brak parametru t', 'Informacja', MB_OK+MB_ICONError);
Edit7.SetFocus; exit; end;
if ( Edit8.Text='') then begin
Application.MessageBox('Brak parametru a', 'Informacja', MB_OK+MB_ICONError);
Edit8.SetFocus; exit; end
else begin
t2 := StrToFloat(Edit7.Text);
a2 := StrToFloat(Edit8.Text);
przyspieszony := a2*sqr(t2)/2;
Edit5.Text := FloatToStr (przyspieszony);
end;
end;
end.