小弟刚初学Delphi不久!请教各位,帮我改一下类赋值问题?(100分)

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

pdrich

Unregistered / Unconfirmed
GUEST, unregistred user!
请教各位,帮我改一下类赋值问题?小弟刚初学Delphi不久!
看有没有最佳这个类设计方法??
程序源代码:
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


{fDate: TDateTime;
procedure SetDay(const Value: Integer);
procedure SetMonth(const Value: Integer);
procedure SetYear(const Value: Integer);
function GetDay: Integer;
function GetMonth: Integer;
function GetYear: Integer
}
public
function Loss_K: Single
// 计算负载K常数值函数
function ResistanceLoss_K: Single
// 计算K2常数值函数
procedure SetValue (K1, K2: Single);

{constructor Create
overload;
constructor Create (y, m, d: Integer)
overload;
procedure SetValue (y, m, d: Integer)
overload;
procedure SetValue (NewDate: TDateTime)
overload;
function LeapYear: Boolean;
procedure Increase (NumberOfDays: Integer = 1);
procedure Decrease (NumberOfDays: Integer = 1);
function GetText: string;
property Year: Integer read GetYear write SetYear;
property Month: Integer read GetMonth write SetMonth;
property Day: Integer read GetDay write SetDay;}
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.
 
已经最佳了[:D]
 
最好不要把方法显露给用户
尽量使用属性进行存取吧
 
你刚学DELPHI??开玩笑呢吧,要不你就是太聪明了,简直是天才!!
 
楼主的水平如果是刚学DELPHI,那对照起来,我的智力应该有问题。
 
哈哈!小弟最近做一个变压质量管理系统!请各位大侠有什么好的见意?
 
后退
顶部