var interface = {

    implements:function(object){

        if(arguments.length < 2) {
            throw{
                name: 'Error',
                message: 'Interface.implements(); called with ' + arguments.length  + 'arguments. Expected at least 2!'
            };
        }

        for(var i = 1, len = arguments.length; i < len; i++) {
            var intf = arguments[i];
            if(intf.constructor !== interface.Interface) {
                throw{
                    name: 'Error',
                    message: 'Interface.implements(); expects arguments two and above to be instances of Interface!'
                };
            }

            var k = intf.methods.length;
            while(k--){
                var method = intf.methods[k];
                if(!object[method] || typeof object[method] !== 'function') {
                    throw{
                        name: 'Error',
                        message: 'Interface.implements(); object does not implement the ' + intf.name + ' interface. ' + method + ' was not found!'
                    };
                }
            }

        }

    }
};


interface.Interface = function(name, methods) {
    if(arguments.length != 2) {
        throw{
            name: 'Error',
            message: 'Interface constructor called with ' + arguments.length + ' arguments. Expected exactly 2!'
        };
    }

    this.name = name;
    this.methods = [];

    var i = methods.length;
    while(i--){
        if(typeof methods[i] !== 'string') {
            throw{
                name: 'Error',
                message: 'Interface constructor expects method names to be passed in as a string!'
            };
        }
        this.methods.push(methods[i]);
    }
};

