-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathFunctionForm.pas
More file actions
150 lines (117 loc) · 3.14 KB
/
FunctionForm.pas
File metadata and controls
150 lines (117 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
unit FunctionForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm2 = class(TForm)
Label1: TLabel;
edtName: TEdit;
Button1: TButton;
edtAge: TEdit;
Label2: TLabel;
Button2: TButton;
Label3: TLabel;
Button3: TButton;
rdoMan: TRadioButton;
rdoWoman: TRadioButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
// 이 폼(유닛)에서 사용하는 변수와 함수를 선언
function GetNameMsg(AName: string): string;
function GetAgeMsg(AName: string; AAge: Integer): string;
function GetUserInfoMsg(AName: string; AAge: Integer; A : boolean): string;
{ TODO :
(2-1) GetUserInfoMsg 함수를 선언
파라메터: 이름(문자), 나이(숫자), 남자여부(Boolean)
반환값: 문자열(메시지)
(2-2) 함수 선언 후 Ctrl + Shift + C를 눌러 구현부 생성
}
public
// 다른 유닛에서 참조할 수 있는 변수와 함수 선언
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
function TForm2.GetNameMsg(AName: string): string;
var
Msg: string;
begin
Msg := '안녕하세요. ';
Msg := Msg + AName + '님';
Result := Msg;
end;
function TForm2.GetUserInfoMsg(AName: string; AAge: Integer;
A: boolean): string;
var
Aman,Msg : string;
begin
AMan := '남자';
if A = false then
AMan := '여자';
Msg := GetAgeMsg(AName, AAge );
Msg := Msg + #13#10 + AName + '님은 ' + AMan + '입니다.' ;
result := Msg;
end;
function TForm2.GetAgeMsg(AName: string; AAge: Integer): string;
var
Msg: string;
Adult : string;
begin
Adult := '미성년';
if AAge >= 20 then
Adult := '성인';
Msg := GetNameMsg(AName); // 인사말 표시는 재사용
Msg := Msg + #13#10 + AName + '님은 ' + inttostr(AAge) + '세로 ' + Adult + '입니다.' ; // 한줄 내려쓰기(일명 캐리지리턴)
{ TODO :
(1) Msg 변수에 '(AName)님은 (AAge)세로 (성인/미성년)입니다.' 메시지 추가
if 문을 이용해 20세 이상(>=)인 경우 성인으로 판단
문자열과 변수를 조합(더하기) 하세요.
정수는 문자로 변환(IntToStr)하세요.
}
Result := Msg;
end;
procedure TForm2.Button1Click(Sender: TObject);
var
Name, Msg: string;
begin
Name := edtName.Text;
Msg := GetNameMsg(Name);
ShowMessage(Msg);
end;
procedure TForm2.Button2Click(Sender: TObject);
var
Name, Msg: string;
Age: Integer;
begin
Name := edtName.Text;
Age := StrToInt(edtAge.Text);
Msg := GetAgeMsg(Name, Age);
ShowMessage(Msg);
end;
procedure TForm2.Button3Click(Sender: TObject);
var
Name, Msg: string;
Age: Integer;
IsMan: Boolean;
begin
Name := edtName.Text;
Age := StrToInt(edtAge.Text);
IsMan := rdoMan.Checked;
MSg := GetUserInfoMsg(Name, Age, IsMan);
{ TODO :
(2) 인사말 + 성인여부 확인 + 성별확인 메시지를
반환하는 함수(GetUserInfoMsg)를 작성하세요
Msg := GetUserInfoMsg(Name, Age, IsMan);
}
ShowMessage(Msg);
end;
{ TODO :
(2-2) GetUserInfoMsg 함수의 구현부에는
인사말 + 성인여부 확인 + 성별확인 메시지를 반환하도록 작성하세요.
이미 구현된 GetNameMsg, GetAgeMsg 등을 재사용하세요.
}
end.