桥接模式--其它设计模式

class Color{
    constructor(name){
        this.name=name;
    }
};
 class Shape{
    constructor(name,color){
        this.name=name;
        this.color=color;
    }
    draw(){
        console.log(this.name+this.color.name);
    }

const red=new Color('red');
const yellow=new Color('yellow');
const circle=new Shape('circle',red);
circle.draw();

发布了234 篇原创文章 · 获赞 24 · 访问量 29万+

猜你喜欢

转载自blog.csdn.net/aliven1/article/details/104031485