标签:com blog class div code java log ext c string color
|
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 |
public class Factory2 { /** * @param args 工厂模式 */ public
static void main(String[] args) { // TODO Auto-generated method stub Ifactory ifactory =new
people1factory(); leifeng student=ifactory.creatLeifeng(); student.wash(); student.buy(); }}//******************************************************************************class
leifeng{//雷锋类 public
void wash() { System.out.println("洗"); } public
void buy() { System.out.println("买"); }}class
people1 extends
leifeng{ public
void wash() { System.out.println("洗1"); } }//人员1class
people2 extends
leifeng{ public
void wash() { System.out.println("洗2"); } }//人员2//******************************************************************************interface
Ifactory{//接口工厂 leifeng creatLeifeng();}//1工厂实现了工厂接口,生产人员1class
people1factory implements
Ifactory{ @Override public
leifeng creatLeifeng() { // TODO Auto-generated method stub return
new people1(); }}//2工厂实现了工厂接口,生产人员2class
people2factory implements
Ifactory{ @Override public
leifeng creatLeifeng() { // TODO Auto-generated method stub return
new people2(); }} |
标签:com blog class div code java log ext c string color
原文地址:http://www.cnblogs.com/daifei/p/3696763.html