just like the factory in real life. Factory produce the production. That is the objects is created by one middle layer class.
Sample:
public class ClothFacotry{
public enum clothType {
hat;
sweater;
shose;
scarf;
}
public cloth getCloth(String clothType){};
}
public interface cloth{
}
Public class hat implement cloth {
public hat(){System.out.print("hat");}
}
public class shose implement cloth{
public shose{System.out.print("shose");}
}
public class sweater implement cloth {
public sweater{System.out.print("sweater");}
}
public class scarf implement cloth{
public scarf{System.out.print("scarf");}
}