在简单工程的上面修改
/**
* @author Liufei
* @date 2020/4/10 2:06 下午
*/
public class Factory {
public Sender productMail() {
return new MailSender();
}
public Sender productSms() {
return new SmsSender();
}
}
/**
* @author Liufei
* @date 2020/4/10 2:08 下午
*/
public class MoreFactoryTest {
public static void main(String[] args) {
Factory factory = new Factory();
Sender sender = factory.productMail();
sender.send();
}
}
来自为知笔记(Wiz)