unit UnitBox;
interface
uses
Classes, Windows, Messages, SysUtils, Variants, TypInfo, ActiveX;
type
TBox = class(TObject)
private
FLong:do
uble;
FWidth:do
uble;
FHeight:do
uble;
function GetAcreage:do
uble;
function GetBulk:do
uble;
public
constructor Create(ALong, AWidth, AHeight:do
uble);
virtual;
destructor Destroy;
override;
property Long:do
uble read FLong write FLong;
property Width:do
uble read FWidth write FWidth;
property Height:do
uble read FHeight write FHeight;
property Acreage:do
uble read GetAcreage;
//面积
property Bulk:do
uble read GetBulk;
//体积
end;
implementation
{ TBox }
constructor TBox.Create(ALong, AWidth, AHeight:do
uble);
begin
FLong := ALong;
FWidth := AWidth;
FHeight := AHeight;
end;
destructor TBox.Destroy;
begin
inherited Destroy;
end;
function TBox.GetAcreage:do
uble;
begin
Result := 2 * (FHeight * FLong + FHeight * FWidth + FLong * FWidth);
end;
function TBox.GetBulk:do
uble;
begin
Result := FHeight * FWidth * FLong;
end;
end.
测试
var
Box:TBox;
....
Box:=TBox.Create(10,10,10);
showmessage(floattostr(Box.Bulk));
Box.free;