File tree Expand file tree Collapse file tree 11 files changed +21
-9
lines changed Expand file tree Collapse file tree 11 files changed +21
-9
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"files.associations" : {
3
- "stdlib.h" : " c"
3
+ "stdlib.h" : " c" ,
4
+ "stdio.h" : " c" ,
5
+ "string.h" : " c" ,
6
+ "memory" : " c" ,
7
+ "utility" : " c" ,
8
+ "type_traits" : " c"
4
9
}
5
10
}
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ void make_iphone()
46
46
// 根据建造者获取对象
47
47
printf ("iphone: %s | " , phone -> name );
48
48
print_phone (phone );
49
+ free_phone_builder (phone_builder );
49
50
50
51
// 创建手册建造者
51
52
ManualBuilder * manual_builder = create_manual_builder ();
@@ -55,6 +56,8 @@ void make_iphone()
55
56
Manual * manual = get_manual_product (manual_builder );
56
57
printf ("iphone manual: %s | " , manual -> name );
57
58
print_manual (manual );
59
+ free_manual_builder (manual_builder );
60
+
58
61
}
59
62
60
63
void make_huawei_phone ()
@@ -67,6 +70,7 @@ void make_huawei_phone()
67
70
// 根据建造者获取对象
68
71
printf ("huawei phone: %s" , phone -> name );
69
72
print_phone (phone );
73
+ free_phone_builder (phone_builder );
70
74
71
75
// 创建手册建造者
72
76
ManualBuilder * manual_builder = create_manual_builder ();
@@ -76,4 +80,5 @@ void make_huawei_phone()
76
80
Manual * manual = get_manual_product (manual_builder );
77
81
printf ("huawei manual: %s" , manual -> name );
78
82
print_manual (manual );
83
+ free_manual_builder (manual_builder );
79
84
}
Original file line number Diff line number Diff line change @@ -14,13 +14,13 @@ typedef struct
14
14
int gpu_type ;
15
15
} Manual ;
16
16
17
- // 定义手册创建者结构体,用来创建Manual对象
17
+ // 定义手册创建者结构体,聚合了Manual对象
18
18
typedef struct
19
19
{
20
20
Phone * phone ;
21
21
} PhoneBuilder ;
22
22
23
- // 定义手册创建者结构体,用来创建Manual对象
23
+ // 定义手册创建者结构体,聚合了Manual对象
24
24
typedef struct
25
25
{
26
26
Manual * manual ;
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ ManualBuilder *create_manual_builder()
15
15
16
16
void reset_manual (ManualBuilder * builder )
17
17
{
18
- // 初始化Phone对象
18
+ // 初始化Manual对象
19
19
Manual * manual = (Manual * )malloc (sizeof (Manual ));
20
20
manual -> name [0 ] = '\0' ;
21
21
int screen_len = (int )sizeof (manual -> screen ) / sizeof (manual -> screen [0 ]);
Original file line number Diff line number Diff line change @@ -23,13 +23,15 @@ int main()
23
23
Phone * phone = get_phone_product (phone_builder );
24
24
printf ("mi phone: %s | " , phone -> name );
25
25
print_phone (phone );
26
+ free_phone_builder (phone_builder );
26
27
27
28
// 创建手册
28
29
ManualBuilder * manual_builder = create_manual_builder ();
29
30
build_mi_manual (manual_builder );
30
31
Manual * manual = get_manual_product (manual_builder );
31
32
printf ("mi manual: %s | " , manual -> name );
32
33
print_manual (manual );
34
+ free_manual_builder (manual_builder );
33
35
}
34
36
35
37
/**
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ func (r *RequestHandler) GetNext() Handler {
23
23
// 如果检查不通过则返回失败,否则继续下一个检查
24
24
func (r * RequestHandler ) Check (uid int ) bool {
25
25
fmt .Println ("RequestHandler::Check() [uid = " + strconv .Itoa (uid ) + "]" )
26
- if uid % 1 ! = 0 {
26
+ if uid % 5 = = 0 {
27
27
return false
28
28
}
29
29
// 通过聚合类来调用下一步检查
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ public class RequestHandler extends AbstractHandler {
5
5
// 如果检查不通过则返回失败,否则继续下一个检查
6
6
public boolean check (int uid ) {
7
7
System .out .println (this .getClass ().getName () + "::check() [uid = " + uid + "]" );
8
- if (uid % 1 ! = 0 ) {
8
+ if (uid % 5 = = 0 ) {
9
9
return false ;
10
10
}
11
11
return checkNext (uid );
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export class RequestHandler extends AbstractHandler {
5
5
// 如果检查不通过则返回失败,否则继续下一个检查
6
6
check ( uid ) {
7
7
console . log ( this . constructor . name + '::check() [uid = ' + uid + ']' )
8
- if ( uid % 1 ! == 0 ) {
8
+ if ( uid % 3 = == 0 ) {
9
9
return false
10
10
}
11
11
return this . checkNext ( uid )
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ class RequestHandler(AbstractHandler):
10
10
# 如果检查不通过则返回失败,否则继续下一个检查
11
11
def check (self , uid ):
12
12
print (self .__class__ .__name__ + '::check() [uid = ' + str (uid ) + ']' )
13
- if (uid % 1 ! = 0 ):
13
+ if (uid % 5 = = 0 ):
14
14
return False
15
15
16
16
return self .checkNext (uid )
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export class RequestHandler extends AbstractHandler {
5
5
// 如果检查不通过则返回失败,否则继续下一个检查
6
6
check ( uid : number ) {
7
7
console . log ( this . constructor . name + '::check() [uid = ' + uid + ']' )
8
- if ( uid % 1 ! == 0 ) {
8
+ if ( uid % 5 = == 0 ) {
9
9
return false
10
10
}
11
11
return this . checkNext ( uid )
You can’t perform that action at this time.
0 commit comments