-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2019-05-10:请列出几种常见的工厂模式并说明它们的用法? #50
Labels
Comments
单例模式,工厂模式,建造者模式,观察者模式 |
这个是建造者模式了 |
//简单工厂模式:
public interface MyAbInterca{
public void a();
}
public class MyInterceImplement implement MyAbInterca{
.......
}
//工厂方法模式:
public abstract class Product {
public abstract void method();
}
public class ConcreteProductA extends Product {
@Override
public void method() {
System.out.println("产品A");
}
}
public class ConcreteProductB extends Product {
@Override
public void method() {
System.out.println("产品B");
}
}
//抽象工厂模式:
public abstract void method();
}
/**
具体产品类A
*/
public class ConcreteProductA extends Product {
@Override
public void method() {
System.out.println(“我是具体的产品A”);
}
}
具体产品类B
*/
public class ConcreteProductB extends Product {
@Override
public void method() {
System.out.println(“我是具体的产品B”);
}
} |
单例模式 |
打卡打卡 去了解一下 |
工厂模式 |
举个案例: 这就是一个工厂模式的案例;使用就是统一的foreach遍历 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: