自由、探索、求知、创新,创造自我

博客园 首页 新随笔 联系 订阅 管理

<script >
function Polygon(iSides){
  this.sides = iSides;
  //alert(this.sides);
}

Polygon.prototype.getArea = function(){
  return 0;
}
function Triangle(iBase,iHeight){
   Polygon.call(this,3);
   this.base = iBase;
   this.height = iHeight;
}
Triangle.prototype = new Polygon();
Triangle.prototype.getArea = function(){
  return 1* this.base * this.height;
}
var t = new  Triangle(3,4);
//alert(t.sides);
alert(t.getArea());
</script>

posted on 2007-02-20 21:43  寂莫渔夫  阅读(242)  评论(0编辑  收藏  举报