Delphi7 (第一天:类的编写)

万恶的delphi,写的超慢。。。。。

万恶的pascal,万恶的begin。。end

我叼!一点都不人性化的设计。我去。

第一天
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Unit1 in 'Pas\Unit1.pas';

  var
    p:Person;
begin
          p:=  Person.Create;
          p.setName('Delphi作者');
          p.setAge(0);
          p.setSex('变态');
          p.speak;
          Readln;
end.
类的编写
unit Unit1;

interface
type

   Person=class
    private
                   name:string;
                   age:Integer;
                   sex:string;
   public
           procedure setName(name:string);
           function  getName:string;
           procedure setAge(age:Integer);
           function  getAge:Integer;
           procedure setSex(sex:string);
           function  getSex:string;
           procedure  speak;

end;


implementation

           procedure Person.setName(name:string);
           begin
                   Self.name:=name;
           end;
           function   Person.getName:string;
           begin
                  Result:= Self.name;
           end;
           procedure Person. setAge(age:Integer);
           begin
                   Self.age:=age;
           end;
           function   Person.getAge:Integer;
           begin
                   Result:=Self.age;
           end;
           procedure  Person.setSex(sex:string);
           begin
                   Self.sex:=sex;
           end;
           function   Person.getSex:string;
           begin
                   Result:=Self.sex;
           end;
           procedure person.speak;
           begin
                   Writeln('我操,写的真慢');
           end;
end.
 
原文地址:https://www.cnblogs.com/anbylau2130/p/3000009.html