|
@@ -0,0 +1,22 @@
|
|
|
+package cn.zyjblogs.design.abstrsctfactory;
|
|
|
+
|
|
|
+
|
|
|
+public class Main {
|
|
|
+ public static void main(String[] args) {
|
|
|
+// AbstractFactory f =new MagicFactory();
|
|
|
+// Vehicle vehicle = f.createVehicle();
|
|
|
+// vehicle.go();
|
|
|
+// Food food = f.createFood();
|
|
|
+// food.printName();
|
|
|
+// Weapon weapon = f.createWeapon();
|
|
|
+// weapon.shoot();
|
|
|
+
|
|
|
+ AbstractFactory f =new ModernFactory();
|
|
|
+ Vehicle vehicle = f.createVehicle();
|
|
|
+ vehicle.go();
|
|
|
+ Food food = f.createFood();
|
|
|
+ food.printName();
|
|
|
+ Weapon weapon = f.createWeapon();
|
|
|
+ weapon.shoot();
|
|
|
+ }
|
|
|
+}
|