为子系统中的一组接口提供一个一致的界面,外观模式定义了一个高层接口,这个接口使得这一子系统更加容易使用。
public class Facade_Main {
public static void main(String[] args) {
ShapDemo demo = new ShapDemo();
demo.drawAShap();
demo.drawBShap();
}
}
interface Shap{
void draw();
}
class AShap implements Shap{
@Override
public void draw() {
System.out.println("AShap...drwa...");
}
}
class BShap implements Shap{
@Override
public void draw() {
System.out.println("BShap...drwa...");
}
}
@Data
class ShapDemo{
private Shap aShap;
private Shap bShap;
public ShapDemo() {
this.aShap = new AShap();
this.bShap = new BShap();
}
public void drawAShap(){
aShap.draw();
}
public void drawBShap(){
bShap.draw();
}
}