Phrogz classical inheritance 1

by BrownieBoy

HTML

<input type="button" onclick="doAction();" value="doAction()"><br>
<br>
<br>

<input name="TestField" value="" id="TestField"></form>

JavaScript

if (typeof Function.prototype.inheritsFrom !== 'function') {
    Function.prototype.inheritsFrom = function(parentClassOrObject) {
        if (parentClassOrObject.constructor == Function) {
            //Normal Inheritance 
            this.prototype = new parentClassOrObject();
            this.prototype.constructor = this;
            this.prototype.parent = parentClassOrObject.prototype;
        }
        else {
            //Pure Virtual Inheritance 
            this.prototype = parentClassOrObject;
            this.prototype.constructor = this;
            this.prototype.parent = parentClassOrObject;
        }
        return this;
    };
}
//

function Person(n, race) {
    this.constructor.population++;

    // ************************************************************************ 
    // PRIVATE VARIABLES AND FUNCTIONS 
    // ONLY PRIVELEGED METHODS MAY VIEW/EDIT/INVOKE 
    // *********************************************************************** 
    var alive = true,
        age = 1;
    var maxAge = 70 + Math.round(Math.random() * 15) + Math.round(Math.random() * 15);

    function makeOlder() {
        return alive = (++age <= maxAge);
    }

    var myName = n ? n : "John Doe";
    var weight = 1;


    // ************************************************************************ 
    // PRIVILEGED METHODS 
    // MAY BE INVOKED PUBLICLY AND MAY ACCESS PRIVATE ITEMS 
    // MAY NOT BE CHANGED; MAY BE REPLACED WITH PUBLIC FLAVORS 
    // ************************************************************************ 
    this.toString = this.getName = function() {
        return myName
    }

    this.eat = function() {
        if (makeOlder()) {
            this.dirtFactor++;
            return weight *= 3;
        } else console.log(myName + " can't eat, he's dead!");
    }
    this.exercise = function() {
        if (makeOlder()) {
            this.dirtFactor++;
            return weight /= 2;
        } else console.log(myName + " can't exercise, he's...