unit blabla;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Spin;
const
cNull = 0;
cFahrenheit = 1;
cCelsius = 2;
cReaumur = 3;
cKelvin = 4;
type
TFormMain =
class(TForm)
LabelTitle: TLabel;
LabelF: TLabel;
LabelR: TLabel;
LabelC: TLabel;
SpinEditF: TSpinEdit;
SpinEditR: TSpinEdit;
SpinEditC: TSpinEdit;
BitBtnCalc: TBitBtn;
BitBtnClose: TBitBtn;
BitBtnClear: TBitBtn;
LabelK: TLabel;
SpinEditK: TSpinEdit;
procedure FormCreate(Sender: TObject);
procedure BitBtnCloseClick(Sender: TObject);
procedure BitBtnCalcClick(Sender: TObject);
procedure SpinEditFChange(Sender: TObject);
procedure SpinEditRChange(Sender: TObject);
procedure SpinEditCChange(Sender: TObject);
procedure BitBtnClearClick(Sender: TObject);
procedure SpinEditKChange(Sender: TObject);
private
{ Private-Deklarationen }
Quelle: Byte;
public
{ Public-Deklarationen }
end;
var
FormMain: TFormMain;
implementation
{$R *.DFM}
procedure TFormMain.FormCreate(Sender: TObject);
begin
Quelle := cNull;
end;
procedure TFormMain.BitBtnCloseClick(Sender: TObject);
begin
Close;
end;
procedure TFormMain.BitBtnCalcClick(Sender: TObject);
begin
case Quelle
of
cFahrenheit:
begin
SpinEditC.Value := Round((SpinEditF.Value-32) / 1.8);
SpinEditR.Value := Round(4/9 * (SpinEditF.Value-32));
SpinEditK.Value := Round(5/9 * (SpinEditF.Value-32) + 273);
end;
cReaumur:
begin
SpinEditC.Value := Round((SpinEditR.Value) / 0.8);
SpinEditF.Value := Round((SpinEditR.Value*1.8) + 32);
SpinEditK.Value := Round(5/4 * SpinEditR.Value + 273);
end;
cCelsius:
begin
SpinEditF.Value := Round((SpinEditC.Value * 1.8) + 32);
SpinEditR.Value := Round(SpinEditC.Value * 0.8);
SpinEditK.Value := Round(SpinEditC.Value + 273);
end;
cKelvin:
begin
SpinEditF.Value := Round(9/5 * (SpinEditK.Value - 273) + 32);
SpinEditR.Value := Round(4/5 * (SpinEditK.Value - 273));
SpinEditC.Value := Round(SpinEditK.Value - 273);
end;
end
end;
procedure TFormMain.SpinEditFChange(Sender: TObject);
begin
Quelle := cFahrenheit;
end;
procedure TFormMain.SpinEditRChange(Sender: TObject);
begin
Quelle := cReaumur;
end;
procedure TFormMain.SpinEditCChange(Sender: TObject);
begin
Quelle := cCelsius;
end;
procedure TFormMain.BitBtnClearClick(Sender: TObject);
begin
Quelle := cNull;
SpinEditC.Value := 0;
SpinEditF.Value := 0;
SpinEditR.Value := 0;
SpinEditK.Value := 0;
end;
procedure TFormMain.SpinEditKChange(Sender: TObject);
begin
Quelle := cKelvin;
end;
end.