This project is read-only.
Project Description
JsOOP is a framework for object-oriented programming (OOP-style) in JavaScript (< 2.0). It allows to define classes in the static language manner. Inheritance and emulation of strong-typing is supported.

The example:

// namespace Zoo
var Zoo = Zoo || {};
 
Zoo.Animal = Class
({
    construct: function(name)
    {
        this._name = name;
    },
 
    vars:
    {
        _name: Type.String
    },
 
    methods:
    {
        Scream: null,
 
        SayName: function()
        {
            return Zoo.Animal.QuoteName(this._name);
        }
    },
 
    statics:
    {
        QuoteName: function(name)
        {
            return "{ " + name + " }";
        }
    }
})
 
Zoo.Dog = Class
({
    base: Zoo.Animal,
 
    construct: function(name, bark, loudness)
    {
        this.$base()(name);
        this._bark = bark;
        this._loudness = loudness;
    },
 
    vars:
    {
        _bark: Type.String,
        _loudness: Type.Number
    },
 
    methods:
    {
        Scream: function()
        {
            var s = "";
            for (var i = 0; i < this._loudness; i++)
            {
                s += this._bark;
            }
            return s;
        },
 
        SayName: function()
        {
            return this._bark + " " + this.$base('SayName')();
        }
    }
})

Last edited Dec 6, 2008 at 11:22 AM by alexeyb, version 3