<html>
<head>
<title>sdfsad</title>
<meta content="text/html; charset=UTF-8"/>
<script type="text/javascript">
Shape = function () {
this.id = null;
this.picture = null;
this.draw = function (canvas) {
this.picture = "由父类产生的图像已经生成在画布上了";
};
};
//1
CommonShape = function () { };
CommonShape.prototype = new Shape();
//2
CrossFillShape = function () {
this.draw = function (canvas) {
CrossFillShape.prototype.draw.apply(this, arguments);
this.picture = this.picture + ", 然后被子类 CrossFillShape 填充";
};
};
CrossFillShape.prototype = new Shape();
//3
SolidFillShape = function () {
this.draw = function (canvas) {
SolidFillShape.prototype.draw.apply(this, arguments);
this.picture = this.picture + ", 然后被子类 SolidFillShape 填充";
};
};
SolidFillShape.prototype = new Shape();
function test1() {
alert("dasfd");
var s = new CommonShape();
s.draw();
alert(s.picture);
var cs = new CrossFillShape();
cs.draw();
alert(cs.picture);
var ss = new SolidFillShape();
ss.draw();
console.debug(ss.picture);
}
</script>
</head>
<body>
<input type="button" value="test1" οnclick="test1()"/><br/>
</body>
</html>
<head>
<title>sdfsad</title>
<meta content="text/html; charset=UTF-8"/>
<script type="text/javascript">
Shape = function () {
this.id = null;
this.picture = null;
this.draw = function (canvas) {
this.picture = "由父类产生的图像已经生成在画布上了";
};
};
//1
CommonShape = function () { };
CommonShape.prototype = new Shape();
//2
CrossFillShape = function () {
this.draw = function (canvas) {
CrossFillShape.prototype.draw.apply(this, arguments);
this.picture = this.picture + ", 然后被子类 CrossFillShape 填充";
};
};
CrossFillShape.prototype = new Shape();
//3
SolidFillShape = function () {
this.draw = function (canvas) {
SolidFillShape.prototype.draw.apply(this, arguments);
this.picture = this.picture + ", 然后被子类 SolidFillShape 填充";
};
};
SolidFillShape.prototype = new Shape();
function test1() {
alert("dasfd");
var s = new CommonShape();
s.draw();
alert(s.picture);
var cs = new CrossFillShape();
cs.draw();
alert(cs.picture);
var ss = new SolidFillShape();
ss.draw();
console.debug(ss.picture);
}
</script>
</head>
<body>
<input type="button" value="test1" οnclick="test1()"/><br/>
</body>
</html>