KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > examples > factory > src > Main


1 package spoon.examples.factory.src;
2
3 import spoon.examples.factory.src.impl1.BImpl1;
4 import spoon.examples.factory.src.impl1.FactoryImpl1;
5 import spoon.examples.factory.src.impl2.FactoryImpl2;
6
7 public class Main {
8
9     public static void main(String JavaDoc[] args) {
10         execute(new FactoryImpl1());
11         execute(new FactoryImpl2());
12     }
13
14     public static void execute(Factory f) {
15         System.out.println("======= running program with factory "+f);
16         A a = f.createA();
17         a.m1();
18         B b = f.createB();
19         b.m2();
20         // that's a mistake: the factory should be used!
21
new BImpl1().m2();
22         // non-factory instantiation
23
new Object JavaDoc();
24     }
25     
26 }
27
Popular Tags