⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bb.pas

📁 delphi的学习资料
💻 PAS
字号:
unit BB;
interface

uses Math;

type
  TCircle = class   // 或 class(TObject)
  private
  public
    dia: Single;    // 直径       // dia 是对外表现的 Filed
    Constructor Create();
    function GetDia(): Single;
    function GetArea(): Single;   // 得到面积
    procedure SetDia(d: Single);
  private
//    procedure SetDia(d: Single);
    Property Fd: Single Read GetDia Write SetDia;  // Fd 是辅助Filed
  end;

var
  circ0: TCircle;

////////////////////////////////////////////////////////////////////////////////
implementation


//============================================================================
Constructor TCircle.Create();
begin
  inherited create;
  dia:=2;
end;

//============================================================================
procedure TCircle.SetDia(d: Single);
begin
  if dia<>d then
    dia:=d;         // 对dia赋值的同时, Fd自动与之一致
end;

//============================================================================
function TCircle.GetDia(): Single;
begin
  Result:=dia;
end;

//============================================================================
function TCircle.GetArea(): Single;
begin
//  Result:=Power(Fd/2,2) *Pi;
  Result:=Power(dia/2,2) *Pi;
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -