zoukankan      html  css  js  c++  java
  • JavaScript 继承总结

     http://blog.csdn.net/yincheng01/article/details/6841953 Metro C++

    http://www.cnblogs.com/michaelxu/archive/2008/09/20/1293716.html 线程同步

    JavaScript 继承总结。三角形和四边形都是继承自多边形

            //多边形
            function Polygon(iSides) {
                this.sides = iSides;
            }
    
            Polygon.prototype.getArea = function () {
                return 0;
            };
    
            //三角形
            function Triangle(iBase, iHeight) {
                Polygon.call(this, 13);
                this.base = iBase;
                this.height = iHeight;
            }
            Triangle.prototype = new Polygon();
            Triangle.prototype.getArea = function () {
                return 0.5 * this.base * this.height;
            };
    
            //四边形
            function Rectangle(iLength, iWidth) {
                Polygon.call(this, 14);
                this.length = iLength;
                this.width = iWidth;
            }
    
            Rectangle.prototype = new Polygon();
            Rectangle.prototype.getArea = function () {
                return this.length * this.width;
            };
        
         //输出结果
            var triangle = new Triangle(122, 4);
            var rectangle = new Rectangle(222, 10);
            alert(triangle.sides); //结果:13
            alert(triangle.getArea()); //结果:244
    
            alert(rectangle.sides); //结果:14
            alert(rectangle.getArea()); //结果:2220
  • 相关阅读:
    MD5 Hashing in Java
    Caching in Presto
    ORC 文件存储格式
    Presto 性能优化点
    数据分页问题
    ES
    ES
    ES
    ES
    ES
  • 原文地址:https://www.cnblogs.com/linlf03/p/2342940.html
Copyright © 2011-2022 走看看