You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
|
|
|
|
public abstract class Creator {
|
|
/**
|
|
* 工厂方法,由具体工厂类实现
|
|
* @return 创建的产品实例
|
|
*/
|
|
public abstract Product factoryMethod();
|
|
|
|
/**
|
|
* 操作方法,使用工厂方法创建的产品
|
|
*/
|
|
public void someOperation() {
|
|
// 调用工厂方法创建产品
|
|
Product product = factoryMethod();
|
|
// 使用产品
|
|
product.operation();
|
|
}
|
|
} |