1type
2 TMan = class(TObject)
3 public
4 procedure sleep(TheHour: Integer);
5 // Public declarations
6 end;
7type
8 TForm1 = class(TForm)
9 Button1: TButton;
10 procedure Button1Click(Sender: TObject);
11 private
12 { Private declarations }
13 public
14 { Public declarations }
15 end;
16
17implementation
18
19
20{ type
21 TMan = class(TObject)
22 public
23 procedure sleep(TheHour: Integer);
24 // Public declarations
25 end;
26PROCEDURE TMan.sleep(TheHour: Integer); //在 implementation里也可以声明类 TMan }
27PROCEDURE TMan.sleep(TheHour: Integer); // 在 interface里声明类 TMan
28BEGIN
29 CASE TheHour OF //
30 0..5: ShowMessage('不睡觉干嘛?') ;
31 6..8: ShowMessage('还是想睡!') ;
32 9..12: ShowMessage('无奈一天已过了一半' + #13 + '起来好了!') ;
33 13..20: ShowMessage('呒,你是小@#') ;
34 21..24: ShowMessage('你和树袋熊是同宗的哦??') ;
35 else
36 ShowMessage('一天只有24小时吧??');
37 END; // case
38END;
39procedure TForm1.Button1Click(Sender: TObject);
40VAR
41 Stime: TMan;
42 i: Integer;
43begin
44 i := StrToInt( InputBox('一天睡事知多少<>','输入每天睡眠时数','8'));
45 Stime := TMan.Create;
46 Stime.sleep(i);
47 Stime.Free;
48end;
49
50
2 TMan = class(TObject)
3 public
4 procedure sleep(TheHour: Integer);
5 // Public declarations
6 end;
7type
8 TForm1 = class(TForm)
9 Button1: TButton;
10 procedure Button1Click(Sender: TObject);
11 private
12 { Private declarations }
13 public
14 { Public declarations }
15 end;
16
17implementation
18
19
20{ type
21 TMan = class(TObject)
22 public
23 procedure sleep(TheHour: Integer);
24 // Public declarations
25 end;
26PROCEDURE TMan.sleep(TheHour: Integer); //在 implementation里也可以声明类 TMan }
27PROCEDURE TMan.sleep(TheHour: Integer); // 在 interface里声明类 TMan
28BEGIN
29 CASE TheHour OF //
30 0..5: ShowMessage('不睡觉干嘛?') ;
31 6..8: ShowMessage('还是想睡!') ;
32 9..12: ShowMessage('无奈一天已过了一半' + #13 + '起来好了!') ;
33 13..20: ShowMessage('呒,你是小@#') ;
34 21..24: ShowMessage('你和树袋熊是同宗的哦??') ;
35 else
36 ShowMessage('一天只有24小时吧??');
37 END; // case
38END;
39procedure TForm1.Button1Click(Sender: TObject);
40VAR
41 Stime: TMan;
42 i: Integer;
43begin
44 i := StrToInt( InputBox('一天睡事知多少<>','输入每天睡眠时数','8'));
45 Stime := TMan.Create;
46 Stime.sleep(i);
47 Stime.Free;
48end;
49
50