forked from hazukac/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathManager.java
More file actions
34 lines (32 loc) · 1.01 KB
/
Copy pathManager.java
File metadata and controls
34 lines (32 loc) · 1.01 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
package framework;
import java.util.HashMap;
public class Manager {
private static Manager mng = null;
private HashMap showcase = new HashMap();
private Manager() {
// なんもかかなくていい
// Manager manager = Manager.getMng();
/*
UnderlinePen ulpen = new UnderlinePen('~');
MessageBox mb = new MessageBox('#');
MessageBox simpleBox = new MessageBox('*');
this.register("strong message", ulpen);
this.register("congrats message", mb);
this.register("simple box", simpleBox);
*/
// }}}
}
public void register(String productName, Product productInstance) {
showcase.put(productName, productInstance);
}
public Product create(String productName) {
Product p = (Product)showcase.get(productName);
return p.createClone();
}
public static Manager getMng() {
if (Manager.mng == null) {
Manager.mng = new Manager();
}
return Manager.mng;
}
}