unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
tstudent=class
private
id:integer;
name:string;
sex:string;
yingyu,delphi0:double;
public
procedure setid(xuehao:integer);
procedure setname(xingming:string);
procedure setsex(xingbie:string);
procedure setlesson(english:double);
procedure setlesson1(delphi:double);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure tstudent.setid(xuehao:integer);
begin
id:=xuehao;
end;
procedure tstudent.setname(xingming:string);
begin
name:=xingming;
end;
procedure tstudent.setsex(xingbie:string);
begin
sex:=xingbie;
end;
procedure tstudent.setlesson(english:double);
begin
yingyu:=english;
end;
procedure tstudent.setlesson1(delphi:double);
begin
delphi0:=delphi;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
stu1:tstudent;
begin
stu1:=tstudent.Create();
stu1.setid(12);
stu1.setname('小明');
stu1.setsex('男');
stu1.setlesson(85);
stu1.setlesson1(90);
edit1.Text:=inttostr(stu1.id);
edit2.Text:=stu1.name;
edit3.Text:=stu1.sex;
edit4.Text:=floattostr(stu1.yingyu);
edit5.Text:=floattostr(stu1.delphi0);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
stu2:tstudent;
begin
stu2:=tstudent.Create();
stu2.setid(28);
stu2.setsex('女');
stu2.setname('小萌');
stu2.setlesson(90);
stu2.setlesson1(99);
edit1.Text:=inttostr(stu2.id);
edit2.Text:=stu2.name;
edit3.Text:=stu2.sex;
edit4.Text:=floattostr(stu2.yingyu);
edit5.Text:=floattostr(stu2.delphi0);
end;
end.