Only do code analysis, not semantic parsing (Senior programmers understand design ideas from code and UML ). The code is from Shang xuexiang and UML is hand-drawn by myself: AbstractFactory. java [java] public abstract class AbstractFactory {public abstract Vehicle createVehicle (); public abstract Weapon createWeapon (); public abstract Food createFood ();} DefaultFactory. java [java] public class DefaultFactory extends AbstractFactory {<span style = "white-space: pre"> </span> @ Override public Food createFood () {// TODO Auto-generated method stub return new Apple () ;}@ Override public Vehicle createVehicle () {// TODO Auto-generated method stub return new Car ();} @ Override public Weapon createWeapon () {// TODO Auto-generated method stub return new AK47 () ;}} MagicFactory. java [java] public class MagicFactory extends AbstractFactory {<span style = "white-space: pre"> </span> @ Override public Food createFood () {// TODO Auto-generated method stub return new MushRoom ();} <span style = "white-space: pre"> </span> @ Override public Vehicle createVehicle () {// TODO Auto-generated method stub return new Broom ();} <span style = "white-space: pre"> </span> @ Override public Weapon createWeapon () {// TODO Auto-generated method stub return new MagicStick () ;}} Food. java [java] public abstract class Food {public abstract void printName ();} Vehicle. java [java] public abstract class Vehicle {public abstract void run ();} Weapon. java [java] public abstract class Weapon {public abstract void shoot ();} Apple. java [java] public class Apple extends Food {public void printName () {System. out. println ("apple") ;}} AK47.java [java] public class AK47 extends Weapon {public void shoot () {System. out. println ("too busy... ") ;}} Car. java [java] public class Car extends Vehicle {public void run () {System. out. println ("smoke your car running ....... ") ;}} Broom. java [java] public class Broom extends Vehicle {<span style = "white-space: pre"> </span> public void run () {System. out. println ("A sandstorm flew all the way to broom ..... ") ;}} MagicStick. java [java] public class MagicStick extends Weapon {@ Override public void shoot () {System. out. println ("fire hu... ") ;}} MushRoom. java [java] public class MushRoom extends Food {<span style = "white-space: pre"> </span> @ Override public void printName () {// TODO Auto-generated method stub System. out. println ("mushroom") ;}} Test. java [java] public class Test {public static void main (String [] args) {AbstractFactory f = new DefaultFactory (); Vehicle v = f. createVehicle (); v. run (); Weapon w = f. createWeapon (); w. shoot (); Food a = f. createFood ();. printName () ;}} UML diagram: Abstract Factory UML Abstract Factory is used to produce finished series products and replace series products...