类的属性赋值方法?(100分)

  • 主题发起人 主题发起人 pdrich
  • 开始时间 开始时间
P

pdrich

Unregistered / Unconfirmed
GUEST, unregistred user!
类的属性赋值方法?
unit uLossClass;

interface
uses
Windows;

type
TLoss = class
private

RatedCapacity: Single
//变压器额定容量 KVA
RatedHighVoltage: Single
//变压器额定高压电压 KV
RatedLowVoltage: Single
//额定低压电压 KV
RatedHighCurrent: Single
//额定高压电流 A
RatedLowCurrent: Single
//额定低压电流 A
ResistanceMeasureTemperature: Single
//电阻测量时温度
LoadMeasureTemperature: Single
//负载测量时温度
HighResistance_OA: Single
//高压电阻OA
HighResistance_OB: Single
//高压电阻OB
HighResistance_OC: Single
//高压电阻OC
LowResistance_ab: Single
//低压电阻ab
LowResistance_bc: Single
//低压电阻bc
LowResistance_ca: Single
//低压电阻ca
VoltageInductorMultiple: Integer
//电压互感器档位
CurrentInductorMultiple: Integer
//电流互感器档位
MeasureVoltage_AB: Single
//测量电压值AB
MeasureVoltage_BC: Single
//测量电压值BC
MeasureVoltage_CA: Single
//测量电压值CA
MeasureCurrent_A: Single
//测量电流值A
MeasureCurrent_B: Single
//测量电流值B
MeasureCurrent_C: Single
//测量电流值C

public
function Loss_K: Single
// 计算负载K常数值函数
function ResistanceLoss_K: Single
// 计算K2常数值函数
procedure SetValue (K1, K2: Single);

end;
implementation

{ TLoss }



{ TLoss }

function TLoss.Loss_K: Single
// 计算负载K常数值函数 

begin
Result :=(235+75)/(235+LoadMeasureTemperature);
end;

function TLoss.ResistanceLoss_K: Single
// 计算K2常数值函数
begin
Result :=(235+LoadMeasureTemperature)/(235+ResistanceMeasureTemperature);
end;

procedure TLoss.SetValue(K1, K2: Single);
begin
ResistanceMeasureTemperature := K1;
LoadMeasureTemperature := K2;

end;

end.


-----------------------------



unit LoadLossFrm;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,uLossClass;

type
TFrmLoadLoss = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FrmLoadLoss: TFrmLoadLoss;

implementation

{$R *.dfm}

procedure TFrmLoadLoss.Button1Click(Sender: TObject);
var
ADay: TLoss;
begin

// create an object
ADay:= TLoss.Create;

// use the object
ADay.SetValue (StrToFloat (Edit1.Text),StrToFloat (Edit2.Text) );
ShowMessage ('K2=' +FloatToStr(ADay.ResistanceLoss_K)+';K1='+FloatToStr(ADay.Loss_K));


end;

end.
 
身连DELPHI。写一个大概给你。看不懂再问。
TMYCLASS=CLASS(TCustomControl)
private
FsCaption:string;
Public
constructor Create(AOwner:TComponent)
Override;
destructor Destroy
Override;
published
property Caption:String Read FsCaption Write FsCaption;
end;
procedure Register;

implementation

procedure Register;
begin
RegisterComponents('MyControl', [TDBOperationButton]);
end;

constructor TMyclass.Create(AOwner:TComponent)

begin
inherited Create(AOwner);
end;
destructor TMyClass.Destroy;
begin
inherited Destroy;
end;

搞定。调用。
VAR
MyClass:TMyClass;
begin
MyClass:=TMyClass.Create(Self);
MyClass.Caption:='test';
end;
 
谢谢楼主
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
627
import
I
I
回复
0
查看
493
import
I
I
回复
0
查看
666
import
I
后退
顶部