<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script language="javascript">
function Speed(x,y){
this.x=x;
this.y=y;
}
Speed.prototype.run=function(){
console.log('跑起来坐标为:'+this.x+':'+this.y);
};
function Color(cl){
this.color=cl;
}
Color.prototype.draw=function(){
console.log('绘制色彩:'+this.color);
};
function Shape(sp){
this.shape=sp;
}
Shape.prototype.change=function(){
console.log('改变形状');
};
function Speek(wd){
this.word=wd;
}
Speek.prototype.say=function(){
console.log('语种:'+this.word);
};
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();
};
var cat=new Ball(100,150,'红色');
cat.init();
function People(x,y,c,wd){
this.speed=new Speed(x,y);
this.color=new Color(c);
this.speek=new Speek(wd);
}
People.prototype.init=function(){
this.speed.run();
this.color.draw();
this.speek.say();
};
var people=new People(130,160,'黄色人种','汉语');
people.init();
</script>
</body>
</html>
|