<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>桥接模式</title>
</head>
<body>
<!--在系统沿着多个多维变化的同时,又不增加其复杂度,并达到解耦-->
<script>
function Speed(x,y) {
this.x = x;
this.y = y;
}
Speed.prototype.run = function () {
console.log("run start");
}
function Color(cl) {
this.cl =cl;
}
Color.prototype.draw = function () {
console.log("draw a color");
}
function Speek(wd) {
this.wd = wd;
}
Speek.prototype.say = function () {
console.log("hello world");
}
function Ball(x,y,c) {
this.speed = new Speed(x,y);
this.color = new Color(c);
}
Ball.prototype.init = function () {
this.speed.run();
this.color.draw();
console.log(this.speed);
console.log(this.color);
}
let ball = new Ball(10,20,'red');
ball.init();
</script>
</body>
</html>