-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNvWa.java
More file actions
37 lines (32 loc) · 1.07 KB
/
NvWa.java
File metadata and controls
37 lines (32 loc) · 1.07 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
package DesignPattern.FactoryMethodPattern;
import DesignPattern.ProxyPattern.WangPo;
/**
* @author [email protected]
* Created by zacky on 22:52.
*/
public class NvWa {
public static void main(String[] args) {
System.out.println("---第一批---白人");
Human whiteHuman = HumanFactory.createHuman(WhiteHuman.class);
whiteHuman.cry();
whiteHuman.laugh();
whiteHuman.talk();
System.out.println("---第二批---黑人");
Human blackHuman = HumanFactory.createHuman(BlackHuman.class);
blackHuman.talk();
blackHuman.laugh();
blackHuman.cry();
System.out.println("---第三批---黄种人");
Human yellowHuman = HumanFactory.createHuman(YellowHuman.class);
yellowHuman.cry();
yellowHuman.laugh();
yellowHuman.talk();
for (int i = 0; i < 1000000; i++) {
System.out.println("---随机造人---" + i);
Human human = HumanFactory.creatHuman();
human.cry();
human.laugh();
human.talk();
}
}
}